Skip to content

[6.x] Add config extra sections with fields to existing fieldtypes - #11712

Closed
nopticon wants to merge 8 commits into
statamic:6.xfrom
nopticon:make-fieldtype-accept-sections
Closed

[6.x] Add config extra sections with fields to existing fieldtypes#11712
nopticon wants to merge 8 commits into
statamic:6.xfrom
nopticon:make-fieldtype-accept-sections

Conversation

@nopticon

Copy link
Copy Markdown
Contributor

After reading https://statamic.dev/extending/fieldtypes#adding-configuration-fields-to-existing-fieldtypes I noticed that extra sections are not added to fieldtype config.

useStatamic\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

This PR adds extra sections support to #5077 and #7706

Be able to create extra sections instead of just single fields.
@duncanmcclean

This comment was marked as resolved.

@nopticon

nopticon commented May 23, 2025

Copy link
Copy Markdown
ContributorAuthor

Hi Duncan! This PR does not add a new method, just enhances how the existing "appendConfigFields" method handles the array when it contains the "fields" key. Please let me know if any questions.

@duncanmcclean

duncanmcclean commented May 23, 2025

Copy link
Copy Markdown
Member

Sorry, ignore me! 🙈

I was reading #5077 and saw extendConfigFields but didn't realise the method name got changed to appendConfigFields before it was merged.

@duncanmccleanduncanmcclean left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you able to add a test for this? It can go in tests/Fields/FieldtypeTest.php.

@nopticon

Copy link
Copy Markdown
ContributorAuthor

Ok will do!

@duncanmccleanduncanmcclean changed the title [5.x] Add config extra sections with fields to existing fieldtypes[6.x] Add config extra sections with fields to existing fieldtypesJan 28, 2026
@duncanmcclean
duncanmcclean changed the base branch from 5.x to 6.xJanuary 28, 2026 17:30
@nopticonnopticon closed this by deleting the head repository Jan 28, 2026
Sign up for freeto 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

@nopticon@duncanmcclean