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;
}
doc_Drupal
2016-10-29 09:40:56
Comments
Leave a Comment

Please login to continue.