X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield_layout%2Fsrc%2FFieldLayoutBuilder.php;h=fdbefd5e8d38c797a4b663daa3e950df829c54cd;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=8ef5d048fc72f48a6ae563bb54bb72c79341f39d;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/field_layout/src/FieldLayoutBuilder.php b/web/core/modules/field_layout/src/FieldLayoutBuilder.php index 8ef5d048f..fdbefd5e8 100644 --- a/web/core/modules/field_layout/src/FieldLayoutBuilder.php +++ b/web/core/modules/field_layout/src/FieldLayoutBuilder.php @@ -67,12 +67,15 @@ class FieldLayoutBuilder implements ContainerInjectionInterface { $regions = array_fill_keys($layout_definition->getRegionNames(), []); foreach ($fields as $name => $field) { - // Move the field from the top-level of $build into a region-specific - // section. + // If the region is controlled by the layout, move the field from the + // top-level of $build into a region-specific section. Custom regions + // could be set by other code at run-time; these should be ignored. // @todo Ideally the array structure would remain unchanged, see // https://www.drupal.org/node/2846393. - $regions[$field['region']][$name] = $build[$name]; - unset($build[$name]); + if (isset($regions[$field['region']])) { + $regions[$field['region']][$name] = $build[$name]; + unset($build[$name]); + } } // Ensure this will not conflict with any existing array elements by // prefixing with an underscore. @@ -103,7 +106,7 @@ class FieldLayoutBuilder implements ContainerInjectionInterface { // avoids breaking hook_form_alter() implementations by not actually // moving the field in the form structure. If a #group is already set, // do not overwrite it. - if (!isset($build[$name]['#group'])) { + if (isset($regions[$field['region']]) && !isset($build[$name]['#group'])) { $build[$name]['#group'] = $field['region']; } }