You are here

function search_form_search_block_form_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/search/search.module \search_form_search_block_form_alter()
  2. 9 core/modules/search/search.module \search_form_search_block_form_alter()

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 416
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;
}