Tabs in fields.yaml not working correctly with mergeConfig()

Hello,

I have two config files both with tabs as the following

CONFIG A:

tabs:
    fields:
        fields_object[margin_top]:
            label: 'Margin Top'
            span: left
            showSearch: false
            options: getSpacingOption
            placeholder: -- select spacing --
            type: dropdown
            tab: 'Block Spacing'

Config B;

tabs:
    fields:
        fields_object[fullwidth]:
            label: 'Full width'
            span: auto
            type: checkbox

i use this in the controller:

            $configA = 'configA.yaml';
            $configB = 'configB.yaml';
            $config = $this->mergeConfig($configA, $configB);

in this case configB is rendered.

Only one is rendered at a time. if i change position of config A with Config B then config A is rendered.

Also if i remove the tabs from Config B then it is working however with no tabs.

thanks alot.

Anyone having the same issue? i cannot find any problems but still the tabs are missing/overwriting in config.

Hi @ibrarartisan

mergeConfig uses a non-recursive merge, like this

(object) array_merge((array) $configA, (array) $configB);

So you may need to specify which item in the configuration you want merged. Like this:

$config = $this->makeConfig($configA);

$config->tabs['fields'] += $this->makeConfig($configB)->tabs['fields'];
1 Like

@daft thanks alot. it works like a charm.