acf-composer icon indicating copy to clipboard operation
acf-composer copied to clipboard

FieldGroup default settings overwrite settings on individual FieldsBuilder instance

Open sanderdv opened this issue 3 years ago • 0 comments

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?

sanderdv avatar Sep 20 '22 13:09 sanderdv