function ClaroHooks::preprocessSelect

Same name and namespace in other branches
  1. 11.x core/themes/claro/src/Hook/ClaroHooks.php \Drupal\claro\Hook\ClaroHooks::preprocessSelect()

Implements hook_preprocess_HOOK() for select.

Attributes

#[Hook('preprocess_select')]

File

core/themes/claro/src/Hook/ClaroHooks.php, line 789

Class

ClaroHooks
Hook implementations for claro.

Namespace

Drupal\claro\Hook

Code

public function preprocessSelect(&$variables) : void {
  if (!empty($variables['element']['#title_display']) && $variables['element']['#title_display'] === 'attribute' && !empty((string) $variables['element']['#title'])) {
    $variables['attributes']['title'] = (string) $variables['element']['#title'];
  }
  $variables['attributes']['class'][] = 'form-element';
  $variables['attributes']['class'][] = $variables['element']['#multiple'] ? 'form-element--type-select-multiple' : 'form-element--type-select';
  if (in_array('block-region-select', $variables['attributes']['class'])) {
    $variables['attributes']['class'][] = 'form-element--extrasmall';
  }
}

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