private function mergeFormConfig(array $parentConfig, array $childConfig)
    {
        // save the fields config for later processing
        $parentFields = $parentConfig['fields'] ?? [];
        $childFields = $childConfig['fields'] ?? [];
        $removedFieldNames = $this->getRemovedFieldNames($childFields);

        // first, perform a recursive replace to merge both configs
        $mergedConfig = \array_replace_recursive($parentConfig, $childConfig);

        // merge the config of each field individually
        $mergedFields = [];
        foreach ($parentFields as $parentFieldName => $parentFieldConfig) {
            if (isset($parentFieldConfig['property']) && \in_array($parentFieldConfig['property'], $removedFieldNames)) {
                continue;
            }

            if (!isset($parentFieldConfig['property'])) {
                // this isn't a regular form field but a special design element (group, section, divider); add it
                $mergedFields[$parentFieldName] = $parentFieldConfig;
                continue;
            }

            $childFieldConfig = $this->findFieldConfigByProperty($childFields, $parentFieldConfig['property']) ?: [];
            $mergedFields[$parentFieldName] = \array_replace_recursive($parentFieldConfig, $childFieldConfig);
        }

        // add back the fields that are defined in child config but not in parent config
        foreach ($childFields as $childFieldName => $childFieldConfig) {
            $isFormDesignElement = !isset($childFieldConfig['property']);
            $isNotRemovedField = isset($childFieldConfig['property']) && 0 !== \strpos($childFieldConfig['property'], '-');
            $isNotAlreadyIncluded = isset($childFieldConfig['property']) && !\array_key_exists($childFieldConfig['property'], $mergedFields);

            if ($isFormDesignElement || ($isNotRemovedField && $isNotAlreadyIncluded)) {
                $mergedFields[$childFieldName] = $childFieldConfig;
            }
        }

        // finally, copy the processed field config into the merged config
        $mergedConfig['fields'] = $mergedFields;

        return $mergedConfig;
    }
private function mergeFormConfig(array $parentConfig, array $childConfig)
    {
        // save the fields config for later processing
        $parentFields = $parentConfig['fields'] ?? [];
        $childFields = $childConfig['fields'] ?? [];
        $removedFieldNames = $this->getRemovedFieldNames($childFields);

        // first, perform a recursive replace to merge both configs
        $mergedConfig = \array_replace_recursive($parentConfig, $childConfig);

        // merge the config of each field individually
        $mergedFields = [];
        foreach ($parentFields as $parentFieldName => $parentFieldConfig) {
            if (isset($parentFieldConfig['property']) && \in_array($parentFieldConfig['property'], $removedFieldNames)) {
                continue;
            }

            if (!isset($parentFieldConfig['property'])) {
                // this isn't a regular form field but a special design element (group, section, divider); add it
                $mergedFields[$parentFieldName] = $parentFieldConfig;
                continue;
            }

            $childFieldConfig = $this->findFieldConfigByProperty($childFields, $parentFieldConfig['property']) ?: [];
            $mergedFields[$parentFieldName] = \array_replace_recursive($parentFieldConfig, $childFieldConfig);
        }

        // add back the fields that are defined in child config but not in parent config
        foreach ($childFields as $childFieldName => $childFieldConfig) {
            $isFormDesignElement = !isset($childFieldConfig['property']);
            $isNotRemovedField = isset($childFieldConfig['property']) && 0 !== \strpos($childFieldConfig['property'], '-');
            $isNotAlreadyIncluded = isset($childFieldConfig['property']) && !\array_key_exists($childFieldConfig['property'], $mergedFields);

            if ($isFormDesignElement || ($isNotRemovedField && $isNotAlreadyIncluded)) {
                $mergedFields[$childFieldName] = $childFieldConfig;
            }
        }

        // finally, copy the processed field config into the merged config
        $mergedConfig['fields'] = $mergedFields;

        return $mergedConfig;
    }
private function mergeFormConfig ( array $ parentConfig , array $ childConfig ) { // save the fields config for later processing $ parentFields = $ parentConfig [ 'fields' ] ?? [ ] ; $ childFields = $ childConfig [ 'fields' ] ?? [ ] ; $ removedFieldNames = $ this -> getRemovedFieldNames ( $ childFields ) ; // first, perform a recursive replace to merge both configs $ mergedConfig = \ array_replace_recursive ( $ parentConfig , $ childConfig ) ; // merge the config of each field individually $ mergedFields = [ ] ; foreach ( $ parentFields as $ parentFieldName => $ parentFieldConfig ) { if ( isset ( $ parentFieldConfig [ 'property' ] ) && \ in_array ( $ parentFieldConfig [ 'property' ] , $ removedFieldNames ) ) { continue ; } if ( ! isset ( $ parentFieldConfig [ 'property' ] ) ) { // this isn't a regular form field but a special design element (group, section, divider); add it $ mergedFields [ $ parentFieldName ] = $ parentFieldConfig ; continue ; } $ childFieldConfig = $ this -> findFieldConfigByProperty ( $ childFields , $ parentFieldConfig [ 'property' ] ) ? : [ ] ; $ mergedFields [ $ parentFieldName ] = \ array_replace_recursive ( $ parentFieldConfig , $ childFieldConfig ) ; } // add back the fields that are defined in child config but not in parent config foreach ( $ childFields as $ childFieldName => $ childFieldConfig ) { $ isFormDesignElement = ! isset ( $ childFieldConfig [ 'property' ] ) ; $ isNotRemovedField = isset ( $ childFieldConfig [ 'property' ] ) && 0 !== \ strpos ( $ childFieldConfig [ 'property' ] , '-' ) ; $ isNotAlreadyIncluded = isset ( $ childFieldConfig [ 'property' ] ) && ! \ array_key_exists ( $ childFieldConfig [ 'property' ] , $ mergedFields ) ; if ( $ isFormDesignElement || ( $ isNotRemovedField && $ isNotAlreadyIncluded ) ) { $ mergedFields [ $ childFieldName ] = $ childFieldConfig ; } } // finally, copy the processed field config into the merged config $ mergedConfig [ 'fields' ] = $ mergedFields ; return $ mergedConfig ; }
Merges the form configuration recursively from the 'form' view to the
'edit' and 'new' views. It processes the configuration of the form fields
in a special way to keep all their configuration and allow overriding and
removing of fields.

@param array $parentConfig The config of the 'form' view
@param array $childConfig  The config of the 'edit' and 'new' views

@return array
Merges the form configuration recursively from the form view to the edit and new views . It processes the configuration of the form fields in a special way to keep all their configuration and allow overriding and removing of fields .