function PreprocessHooks::fieldset
Same name and namespace in other branches
- main core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::fieldset()
Implements hook_preprocess_HOOK() for fieldset.
Attributes
#[Hook('preprocess_fieldset')]
File
-
core/
themes/ admin/ src/ Hook/ PreprocessHooks.php, line 404
Class
- PreprocessHooks
- Provides preprocess implementations.
Namespace
Drupal\admin\HookCode
public function fieldset(array &$variables) : void {
$element = $variables['element'];
$composite_types = [
'checkboxes',
'radios',
];
if (!empty($element['#type']) && !empty($variables['element']['#children_errors']) && in_array($element['#type'], $composite_types, TRUE)) {
$variables['legend_span']['attributes']->addClass('has-error');
}
if (!empty($element['#disabled'])) {
$variables['legend_span']['attributes']->addClass('is-disabled');
if (!empty($variables['description']) && !empty($variables['description']['attributes'])) {
$variables['description']['attributes']->addClass('is-disabled');
}
}
// Remove 'container-inline' class from the main attributes and add a flag
// instead.
// @todo Remove this after https://www.drupal.org/node/3059593 has been
// resolved.
if (!empty($variables['attributes']['class'])) {
$container_inline_key = array_search('container-inline', $variables['attributes']['class'], TRUE);
if ($container_inline_key !== FALSE) {
unset($variables['attributes']['class'][$container_inline_key]);
$variables['inline_items'] = TRUE;
}
}
$this->preprocessDescriptionToggle($variables);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.