Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
413 stars 56 forks source link

FieldGroup default settings overwrite settings on individual FieldsBuilder instance #127

Closed sanderdv closed 1 year ago

sanderdv commented 1 year ago

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 commented 1 year ago

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

sanderdv commented 1 year ago

Yes of course, here it is: https://github.com/Log1x/acf-composer/pull/132