function olivero_preprocess_fieldset

Same name in other branches
  1. 9 core/themes/olivero/olivero.theme \olivero_preprocess_fieldset()
  2. 11.x core/themes/olivero/olivero.theme \olivero_preprocess_fieldset()

Implements template_preprocess_HOOK() for fieldset.

File

core/themes/olivero/olivero.theme, line 450

Code

function olivero_preprocess_fieldset(&$variables) {
    $element = $variables['element'];
    $composite_types = [
        'checkboxes',
        'radios',
    ];
    if (!empty($element['#type']) && in_array($element['#type'], $composite_types) && !empty($variables['element']['#children_errors'])) {
        $variables['legend_span']['attributes']->addClass('has-error');
    }
    if (!empty($element['#disabled'])) {
        $variables['legend_span']['attributes']->addClass('is-disabled');
        if (!empty($variables['description']) && !empty($variables['description']['attributes'])) {
            $variables['description']['attributes']->addClass('is-disabled');
        }
    }
    // Remove 'container-inline' class from the main attributes and add a flag
    // instead.
    // @todo remove this after https://www.drupal.org/node/3059593 has been
    //   resolved.
    if (!empty($variables['attributes']['class'])) {
        $container_inline_key = array_search('container-inline', $variables['attributes']['class']);
        if ($container_inline_key !== FALSE) {
            unset($variables['attributes']['class'][$container_inline_key]);
            $variables['inline_items'] = TRUE;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.