function PreprocessHooks::formElement
Same name and namespace in other branches
- main core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::formElement()
Implements hook_preprocess_HOOK() for form_element.
Attributes
#[Hook('preprocess_form_element')]
File
-
core/
themes/ admin/ src/ Hook/ PreprocessHooks.php, line 554
Class
- PreprocessHooks
- Provides preprocess implementations.
Namespace
Drupal\admin\HookCode
public function formElement(array &$variables) : void {
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');
}
}
$this->preprocessDescriptionToggle($variables);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.