You are here

function olivero_preprocess_form_element in Drupal 9

Implements hook_preprocess_form_element().

File

core/themes/olivero/olivero.theme, line 249
Functions to support theming in the Olivero theme.

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';
  }
}