Skip to content
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

FieldGroup default settings overwrite settings on individual FieldsBuilder instance #127

Closed
sanderdv opened this issue Sep 20, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@sanderdv
Copy link
Contributor

I've noticed that the settings I set for a field_group in config/acf.php override the settings I have on individual FieldsBuilder instances. For example:

FieldsBuilder

$frontPage = new FieldsBuilder('front_page', ['title' => 'Custom title']);

ACF config

'defaults' => [
    'field_group' => [
        'title' => 'Default title'
    ]
]

In this case, the title will be 'Default title', where I expected it to be 'Custom title'.

When I change the order the field_group defaults are merged in Log1x\AcfComposer\Composer on line 64 from this:
$this->fields = array_merge($this->fields ?? [], $this->defaults->get('field_group'));
to this:
$this->fields = array_merge($this->defaults->get('field_group'), $this->fields ?? []);
the title is 'Custom title', as expected. It looks like this fixes my issue, but I'm not sure if there are any other implications?

@Log1x
Copy link
Owner

Log1x commented Sep 27, 2022

I think that should be fine. Would you like to open a PR?

@Log1x Log1x added the bug Something isn't working label Oct 6, 2022
@sanderdv
Copy link
Contributor Author

Yes of course, here it is: #132

@Log1x Log1x closed this as completed in 38dc07b Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants