Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[6.x] Add extra sections with fields to existing fieldtypes#13796

Open
nopticon wants to merge 6 commits intostatamic:6.x from
nopticon:feature/make-fieldtype-accept-sections
Open

[6.x] Add extra sections with fields to existing fieldtypes #13796
nopticon wants to merge 6 commits intostatamic:6.x from
nopticon:feature/make-fieldtype-accept-sections

Conversation

@nopticon
Copy link
Contributor

@nopticon nopticon commented Feb 2, 2026

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.

use Statamic\Fieldtypes\Text;
Text::appendConfigFields([
 [
 'display' => __('Extra section'),
 'fields' => [
 'more_options' => [
 'display' => __('Options'),
 'instructions' => __('Instructions for this field'),
 'type' => 'array',
 ],
 ],
 ],
]);

Before this fix, it shows like this:

image

After fixing this issue, it shows fields inside the new section:

image

After adding appendConfigFields to a ServiceProvider, it can be tested on any blueprint at /cp/collections/{collection}/blueprints/{blueprint}/edit

@nopticon nopticon marked this pull request as draft February 2, 2026 18:31
@nopticon nopticon marked this pull request as ready for review February 2, 2026 18:31
@nopticon nopticon changed the title (削除) [6.x] Add config extra sections with fields to existing fieldtypes (削除ここまで) (追記) [6.x] Add extra sections with fields to existing fieldtypes (追記ここまで) Feb 2, 2026
@nopticon nopticon marked this pull request as draft February 2, 2026 18:41
Copy link
Contributor

Related: #12723

@nopticon nopticon marked this pull request as ready for review February 3, 2026 05:38

private function extraConfigFieldsUseSections($extras)
{
return collect($extras)->filter(fn ($field) => Arr::has($field, 'fields'));
Copy link
Contributor

@ryanmitchell ryanmitchell Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@nopticon nopticon Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ryanmitchell Are you referring to replicators and bard fields that you want to add with appendConfigFields method? Something like this:

image

This check does validate fields key on the first level of the array generated by

protected function extraConfigFieldItems(): array
but it's not recursive for other 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():

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@ryanmitchell ryanmitchell ryanmitchell left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

No way of appending config fields with a section title

AltStyle によって変換されたページ (->オリジナル) /