function ClaroHooks::preprocessFieldMultipleValueForm
Implements hook_preprocess_HOOK() for field_multiple_value_form.
Attributes
#[Hook('preprocess_field_multiple_value_form')]
File
-
core/
themes/ claro/ src/ Hook/ ClaroHooks.php, line 852
Class
- ClaroHooks
- Hook implementations for claro.
Namespace
Drupal\claro\HookCode
public function preprocessFieldMultipleValueForm(&$variables) : void {
// Make disabled available for the template.
$variables['disabled'] = !empty($variables['element']['#disabled']);
if ($variables['multiple']) {
// Add an additional CSS class to the field label table cell. The table
// header cell should always exist unless removed by contrib.
// @see \Drupal\Core\Field\FieldPreprocess::preprocessFieldMultipleValueForm().
if (isset($variables['table']['#header'][0]['data']['#attributes'])) {
$variables['table']['#header'][0]['data']['#attributes']->removeClass('label');
$variables['table']['#header'][0]['data']['#attributes']->addClass('form-item__label', 'form-item__label--multiple-value-form');
}
if ($variables['disabled']) {
$variables['table']['#attributes']['class'][] = 'tabledrag-disabled';
$variables['table']['#attributes']['class'][] = 'js-tabledrag-disabled';
// We will add the 'is-disabled' CSS class to the disabled table header
// cells.
$header_attributes['class'][] = 'is-disabled';
foreach ($variables['table']['#header'] as &$cell) {
if (is_array($cell) && isset($cell['data'])) {
$cell = $cell + [
'class' => [],
];
$cell['class'][] = 'is-disabled';
}
else {
// We have to modify the structure of this header cell.
$cell = [
'data' => $cell,
'class' => [
'is-disabled',
],
];
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.