diff -u b/core/includes/form.inc b/core/includes/form.inc --- b/core/includes/form.inc +++ b/core/includes/form.inc @@ -312,7 +312,6 @@ $variables['legend']['title'] = (isset($element['#title']) && $element['#title'] !== '') ? Xss::filterAdmin($element['#title']) : ''; $variables['legend']['attributes'] = new Attribute(); - $variables['legend_span']['attributes'] = new Attribute(); if (!empty($element['#description'])) { @@ -324,11 +323,6 @@ // Add the description's id to the fieldset aria attributes. $variables['attributes']['aria-describedby'] = $description_id; } - - // Pass element's #type to template. - if (!empty($element['#type'])) { - $variables['type'] = $element['#type']; - } } /** @@ -551,7 +545,7 @@ $variables['attributes']['id'] = $element['#id']; } - // Pass element's #type and #name to template. + // Pass elements #type and #name to template. if (!empty($element['#type'])) { $variables['type'] = $element['#type']; } @@ -559,7 +553,7 @@ $variables['name'] = $element['#name']; } - // Pass element's disabled status to template. + // Pass elements disabled status to template. $variables['disabled'] = !empty($element['#attributes']['disabled']) ? $element['#attributes']['disabled'] : NULL; // If #title is not set, we don't display any label. @@ -618,7 +612,7 @@ $variables['title'] = (isset($element['#title']) && $element['#title'] !== '') ? Xss::filterAdmin($element['#title']) : ''; $variables['attributes'] = array(); - // Pass element's title_display to template. + // Pass elements title_display to template. $variables['title_display'] = $element['#title_display']; // A #for property of a dedicated #type 'label' element as precedence. @@ -635,7 +629,7 @@ $variables['attributes']['for'] = $element['#id']; } - // Pass element's required to template. + // Pass elements required to template. $variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL; } reverted: --- b/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php +++ a/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php @@ -33,6 +33,8 @@ if (isset($element['#title']) || isset($element['#description'])) { // @see #type 'fieldgroup' $element['#theme_wrappers'][] = 'fieldset'; + $element['#attributes']['class'][] = 'fieldgroup'; + $element['#attributes']['class'][] = 'form-composite'; } return $element; } diff -u b/core/modules/system/templates/fieldset.html.twig b/core/modules/system/templates/fieldset.html.twig --- b/core/modules/system/templates/fieldset.html.twig +++ b/core/modules/system/templates/fieldset.html.twig @@ -7,7 +7,6 @@ * - attributes: HTML attributes for the fieldset element. * - required: The required marker or empty if the associated fieldset is * not required. - * - type: The type of the element. * - legend: The legend element containing the following properties: * - title: Title of the fieldset, intended for use as the text of the legend. * - attributes: HTML attributes to apply to the legend. @@ -23,21 +22,7 @@ * @ingroup themeable */ #} -{% if type in ['radios', 'checkboxes'] %} - {% - set composite_element_classes = [ - 'fieldgroup', - 'form-composite', - ] - %} -{% endif %} - - {% if legend.title is not empty or required -%} - {% - set legend_classes = [ - title_display == 'invisible' ? 'visually-hidden', - ] - %} + {% set legend_span_classes = [ 'fieldset-legend', @@ -45,7 +30,7 @@ ] %} {# Always wrap fieldset legends in a SPAN for CSS positioning. #} - + {{ legend.title }} {%- endif %} diff -u b/core/modules/system/templates/form-element-label.html.twig b/core/modules/system/templates/form-element-label.html.twig --- b/core/modules/system/templates/form-element-label.html.twig +++ b/core/modules/system/templates/form-element-label.html.twig @@ -5,7 +5,7 @@ * * Available variables: * - title: The label's text. - * - title_display: Element's title_display setting. + * - title_display: Elements title_display setting. * - required: An indicator for whether the associated form element is required. * - attributes: A list of HTML attributes for the label. *