function PreprocessHooks::select

Same name and namespace in other branches
  1. main core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::select()

Implements hook_preprocess_HOOK() for select.

Attributes

#[Hook('preprocess_select')]

File

core/themes/admin/src/Hook/PreprocessHooks.php, line 1086

Class

PreprocessHooks
Provides preprocess implementations.

Namespace

Drupal\admin\Hook

Code

public function select(array &$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'], TRUE)) {
    $variables['attributes']['class'][] = 'form-element--extrasmall';
  }
  if (in_array('block-weight', $variables['attributes']['class'], TRUE)) {
    $variables['attributes']['class'][] = 'form-element--extrasmall';
  }
}

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