function bartik_form_alter in Drupal 8
Same name and namespace in other branches
- 9 core/themes/bartik/bartik.theme \bartik_form_alter()
- 10 core/themes/bartik/bartik.theme \bartik_form_alter()
Implements hook_form_alter() to add classes to the search form.
File
- core/
themes/ bartik/ bartik.theme, line 117 - Functions to support theming in the Bartik theme.
Code
function bartik_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, [
'search_block_form',
'search_form',
])) {
$key = $form_id == 'search_block_form' ? 'actions' : 'basic';
if (!isset($form[$key]['submit']['#attributes'])) {
$form[$key]['submit']['#attributes'] = new Attribute();
}
$form[$key]['submit']['#attributes']
->addClass('search-form__submit');
}
}