[6.x] Forms 2: Add appendConfigFields to form fieldtypes - #15331
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q49Rea3WHrqiVjZ5azU7FG
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
appendConfigFields to form fieldtypes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaFieldtype::appendConfigField()never showed up in the Form Builder.FormFieldtypenow has its ownappendConfigFields()andappendConfigField()methods, mirroring the existingFieldtypeAPI. You can append to a specific form fieldtype, or to every form fieldtype by calling it on theFormFieldtypebase class: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
textfields 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.