Skip to content

[6.x] Forms 2: Add appendConfigFields to form fieldtypes - #15331

Merged
jasonvarga merged 2 commits into
forms-2from
forms-2-wrapped-config-fields
Sep 1, 2026
Merged

[6.x] Forms 2: Add appendConfigFields to form fieldtypes#15331
jasonvarga merged 2 commits into
forms-2from
forms-2-wrapped-config-fields

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Sep 1, 2026

Copy link
Copy Markdown
Member

This pull request adds a way for addons to append config fields to form fieldtypes.

Form fields use dedicated form fieldtypes (eg. Short Answer, Dropdown) which wrap a regular fieldtype under the hood (Short Answer wraps text).

These build their config fields from their own curated configFieldItems(), so addons appending config fields to a regular fieldtype via Fieldtype::appendConfigField() never showed up in the Form Builder.

FormFieldtype now has its own appendConfigFields() and appendConfigField() methods, mirroring the existing Fieldtype API. You can append to a specific form fieldtype, or to every form fieldtype by calling it on the FormFieldtype base class:

use Statamic\Forms\Fieldtypes\ShortAnswer;

ShortAnswer::appendConfigField('character_limit', [
    'display' => 'Character Limit',
    'type' => 'integer',
]);

Backwards compatibility

This PR also bridges config fields appended to a wrapped fieldtype (eg. Text::appendConfigField()) onto the form fieldtypes that wrap it, so addons written against the old API keep working without changes. If both APIs append a field with the same handle, the form fieldtype's own append wins.

This "bridge" is temporary and marked with a TODO to be removed in v7. Appending to the wrapped fieldtype is indirect — the addon is really targeting text fields everywhere (entries, globals, etc.), and only reaches forms because form fieldtypes happen to wrap regular fieldtypes as an implementation detail.

The bridge exists purely because Forms 2 ships in a minor release where existing addons can't be broken. By v7, addons should append to form fieldtypes directly using the new API.

duncanmcclean and others added 2 commits September 1, 2026 12:57
gives `FormFieldtype` its own `appendConfigFields()` / `appendConfigField()` methods as the successor to appending config fields via the wrapped fieldtype, which is now a bridge to be removed in v7 once addons have migrated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Rj7A1gzpwpJHka5CF6Mee
@duncanmcclean duncanmcclean changed the title [6.x] Forms 2: Include config fields appended to wrapped fieldtypes [6.x] Forms 2: Appending Config Fields to Form Fieldtypes Sep 1, 2026
@duncanmcclean duncanmcclean changed the title [6.x] Forms 2: Appending Config Fields to Form Fieldtypes [6.x] Forms 2: Add appendConfigFields to form fieldtypes Sep 1, 2026
@jasonvarga
jasonvarga merged commit a14cf34 into forms-2 Sep 1, 2026
65 checks passed
@jasonvarga
jasonvarga deleted the forms-2-wrapped-config-fields branch September 1, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants