Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

add fields to form-fields #35

Closed
@glettl

Description

@glettl

Currently it is possible to overwrite the fields of the form-field blocks completely, but it is not possible to add an additional custom field.

If I'd like to add the custom field 'test', all other fields are gone.

formBuilder({ fields: { email: { fields: [ { name: 'test', type: 'text', }, ], }, }, })

I think, it's because the the merge in

arrayMerge: (_, sourceArray) => sourceArray

is configured to replace the fields array.

I know that there are cases where one wants to redefine all form-fields, however it would be nice if a way to simply add custom fields to an form-field could be provided.

I thought about two possible ways to achieve this:

  1. add an additional property 'addFields' to the formBuilder incomingFormConfig.field.[FIELD_SLUG] object and add these fields after the merge step of the generateFormCollection function.
  2. expose the definition of the default form-fields configuration so that it can be imported and be reused the custom config. E.g. like this:
    import formFields from '@payloadcms/plugin-form-builder/'; [...] formBuilder({ fields: { email: { fields: [ ...formFields.email.fields, { name: 'test', type: 'text', }, ], }, }, })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions