function olivero_preprocess_form_element

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

Implements hook_preprocess_form_element().

File

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

Code

function olivero_preprocess_form_element(&$variables) {
    if (in_array($variables['element']['#type'] ?? FALSE, [
        'checkbox',
        'radio',
    ], TRUE)) {
        $variables['attributes']['class'][] = 'form-type-boolean';
    }
    if (!empty($variables['description']['attributes'])) {
        $variables['description']['attributes']->addClass('form-item__description');
    }
    if ($variables['disabled']) {
        $variables['label']['#attributes']['class'][] = 'is-disabled';
    }
}

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