diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 7eb7e0f..068f719 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -774,6 +774,15 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // Recurse through all child elements. $count = 0; + if (isset($element['#access'])) { + $access = $element['#access']; + if ($access instanceof AccessResultInterface || $access === FALSE) { + $child_denied = $access; + } + else { + $child_access = NULL; + } + } foreach (Element::children($element) as $key) { // Prior to checking properties of child elements, their default // properties need to be loaded. @@ -788,8 +797,8 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state } // Deny access to child elements if parent is denied. - if (isset($element['#access']) && (($element['#access'] instanceof AccessResultInterface && !$element['#access']->isAllowed()) || !$element['#access'])) { - $element[$key]['#access'] = FALSE; + if (isset($child_access)) { + $element[$key]['#access'] = $child_access; } // Make child elements inherit their parent's #disabled and #allow_focus