function seven_form_alter in Drupal 8
Same name and namespace in other branches
- 9 core/themes/seven/seven.theme \seven_form_alter()
- 10 core/themes/seven/seven.theme \seven_form_alter()
Implements hook_form_alter().
File
- core/
themes/ seven/ seven.theme, line 209 - Functions to support theming in the Seven theme.
Code
function seven_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
$form_object = $form_state
->getFormObject();
if ($form_object instanceof ViewsForm && strpos($form_object
->getBaseFormId(), 'views_form_media_library') === 0) {
if (isset($form['header'])) {
$form['header']['#attributes']['class'][] = 'media-library-views-form__header';
$form['header']['media_bulk_form']['#attributes']['class'][] = 'media-library-views-form__bulk_form';
}
$form['actions']['submit']['#attributes']['class'] = [
'media-library-select',
];
}
// Add after build to add a CSS class to the form actions.
if ($form_id === 'views_exposed_form' && strpos($form['#id'], 'views-exposed-form-media-library-widget') === 0) {
$form['actions']['#attributes']['class'][] = 'media-library-view--form-actions';
}
}