You are here

function claro_preprocess_form_element in Drupal 9

Same name and namespace in other branches
  1. 8 core/themes/claro/claro.theme \claro_preprocess_form_element()
  2. 10 core/themes/claro/claro.theme \claro_preprocess_form_element()

Implements hook_preprocess_form_element().

File

core/themes/claro/claro.theme, line 765
Functions to support theming in the Claro theme.

Code

function claro_preprocess_form_element(&$variables) {
  if (!empty($variables['element']['#errors'])) {
    $variables['label']['#attributes']['class'][] = 'has-error';
  }
  if ($variables['disabled']) {
    $variables['label']['#attributes']['class'][] = 'is-disabled';
    if (!empty($variables['description']['attributes'])) {
      $variables['description']['attributes']
        ->addClass('is-disabled');
    }
  }
}