You are here

function bartik_form_alter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 116
Functions to support theming in the Bartik theme.

Code

function bartik_form_alter(&$form, \Drupal\Core\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');
  }
}