[6.x] Add extra sections with fields to existing fieldtypes#13796
Open
nopticon wants to merge 6 commits intostatamic:6.xfrom
Open
[6.x] Add extra sections with fields to existing fieldtypes#13796nopticon wants to merge 6 commits intostatamic:6.xfrom
nopticon wants to merge 6 commits intostatamic:6.xfrom
Conversation
Contributor
|
Related: #12723 |
ryanmitchell
reviewed
Feb 3, 2026
|
|
||
| private function extraConfigFieldsUseSections($extras) | ||
| { | ||
| return collect($extras)->filter(fn ($field) => Arr::has($field, 'fields')); |
Contributor
There was a problem hiding this comment.
Not sure this is the right way to check, as replicators and bards both have fields so this check would mark them both as sections.
Contributor
Author
There was a problem hiding this comment.
Hi @ryanmitchell Are you referring to replicators and bard fields that you want to add with appendConfigFields method? Something like this:
This check does validate fields key on the first level of the array generated by
Line 293 in 80f7049
fields keys, so I haven't seen the behavior that you mentioned. This PR does not affect other existing fields beside the ones that you define calling appendConfigField or appendConfigFields method.
I did a lot of tests in my dev site and all fields seems to be working fine, if you see something weird is happening please let me know. Thanks for your review!
This is how it looks for my custom test calling Text::appendConfigFields():
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.
After reading https://statamic.dev/fieldtypes/build-a-fieldtype#adding-config-fields-to-existing-fieldtypes I noticed that extra sections are not added to fieldtype config.
Before this fix, it shows like this:
After fixing this issue, it shows fields inside the new section:
After adding
appendConfigFieldsto a ServiceProvider, it can be tested on any blueprint at/cp/collections/{collection}/blueprints/{blueprint}/edit