8.3.x bartik.theme bartik_form_alter(&$form, FormStateInterface $form_state, $form_id)
8.0.x bartik.theme bartik_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
8.1.x bartik.theme bartik_form_alter(&$form, FormStateInterface $form_state, $form_id)
8.2.x bartik.theme bartik_form_alter(&$form, FormStateInterface $form_state, $form_id)
8.4.x bartik.theme bartik_form_alter(&$form, FormStateInterface $form_state, $form_id)

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');
  }
}