function search_form_search_block_form_alter

search_form_search_block_form_alter(&$form, FormStateInterface $form_state)

Implements hook_form_FORM_ID_alter() for the search_block_form form.

Since the exposed form is a GET form, we don't want it to send the form tokens. However, you cannot make this happen in the form builder function itself, because the tokens are added to the form after the builder function is called. So, we have to do it in a form_alter.

See also

\Drupal\search\Form\SearchBlockForm

File

core/modules/search/search.module, line 921
Enables site-wide keyword searching.

Code

function search_form_search_block_form_alter(&$form, FormStateInterface $form_state) {
  $form['form_build_id']['#access'] = FALSE;
  $form['form_token']['#access'] = FALSE;
  $form['form_id']['#access'] = FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!search!search.module/function/search_form_search_block_form_alter/8.1.x