Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend formBuilderPlugin fields: not persist data #7787

Open
matteo-naif opened this issue Aug 21, 2024 · 3 comments
Open

Extend formBuilderPlugin fields: not persist data #7787

matteo-naif opened this issue Aug 21, 2024 · 3 comments
Labels
stale status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@matteo-naif
Copy link

Link to reproduction

Payload Version

3.0.0-beta.86

Node Version

v20

Next.js Version

15.0.0-canary.121

Describe the Bug

If I add a custom field in the plugin configuration, it displays correctly in the admin UI but the data is not persisted.
If I add the "slug" property the data is persisted but there is a typescript error because is missing in the interface FieldConfig.

Reproduction Steps

  1. Declare the custom field
import { fields, formBuilderPlugin } from "@payloadcms/plugin-form-builder";
import { Block } from "payload";

export const formBuilderPluginConfig = formBuilderPlugin({
    redirectRelationships: ["pages"],
    fields: {
        hidden: {
            // slug: "hidden", // <- With this prop works
            labels: {
                singular: 'Hidden',
                plural: 'Hidden'
            },
            fields: [
                ...(fields.text as Block).fields
                // Other fields
            ]
        }
    },
})
  1. Open the Admin UI to add the custom field
  2. Save
  3. Data is not persisted

Adapters and Plugins

"@payloadcms/db-mongodb": "beta",     "@payloadcms/email-nodemailer": "beta",     "@payloadcms/next": "beta",     "@payloadcms/plugin-cloud-storage": "beta",     "@payloadcms/plugin-form-builder": "beta",     "@payloadcms/plugin-nested-docs": "beta",     "@payloadcms/plugin-seo": "beta",     "@payloadcms/richtext-lexical": "beta",     "@payloadcms/storage-s3": "beta",     "@payloadcms/ui": "beta",
@matteo-naif matteo-naif added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Aug 21, 2024
@denolfe denolfe removed the v3 label Nov 19, 2024
@siobahnschuck
Copy link

@matteo-naif did you find a work around for this? running into this same issue currently. Also trying to add a custom "hidden" field to the formBuilder plugin.

@matteo-naif
Copy link
Author

matteo-naif commented Dec 6, 2024

Hi @siobahnschuck, I paste my working example with minimal setup.
At the moment the type FieldConfig still is missing the slug property.

import { formBuilderPlugin } from "@payloadcms/plugin-form-builder";
import { fields } from "@payloadcms/plugin-form-builder";
import { FieldConfig } from "@payloadcms/plugin-form-builder/types";
import { Block } from "payload";

export const textFields = (fields.text as Block).fields

export const InputHidden: FieldConfig = {
    // @ts-ignore
    slug: "hidden",
    labels: {
        singular: 'Hidden',
        plural: 'Hidden'
    },
    fields: [
        ...textFields
        // Other fields
    ]
};

export const formBuilderPluginConfig = formBuilderPlugin({
    redirectRelationships: ["pages"],
    fields: {
        hidden: InputHidden
    }
})

The result is the following:

Image

@siobahnschuck
Copy link

@matteo-naif thank you so much! This works well 🌟

@github-actions github-actions bot added the stale label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

3 participants