function PreprocessHooks::fieldMultipleValueForm
Same name and namespace in other branches
- 11.x core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::fieldMultipleValueForm()
Implements hook_preprocess_HOOK() for field_multiple_value_form.
Attributes
#[Hook('preprocess_field_multiple_value_form')]
File
-
core/
themes/ admin/ src/ Hook/ PreprocessHooks.php, line 363
Class
- PreprocessHooks
- Provides preprocess implementations.
Namespace
Drupal\admin\HookCode
public function fieldMultipleValueForm(array &$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 += [
'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.