Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 5.x
Choose a base branch
from

Conversation

nopticon
Copy link
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.

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

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
Copy link
Contributor Author

nopticon commented May 23, 2025

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
Copy link
Member

duncanmcclean commented May 23, 2025

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.

Copy link
Member

@duncanmcclean duncanmcclean left a comment

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
Contributor Author

Ok will do!

@nopticon nopticon requested a review from duncanmcclean May 24, 2025 00:14
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.

2 participants