Skip to content

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
@ryanmitchell
Copy link
Contributor

Related: #12723

@duncanmcclean duncanmcclean linked an issue Feb 2, 2026 that may be closed by this pull request
@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

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way of appending config fields with a section title

2 participants