function search_form_search_block_form_alter
Same name in other branches
- 8.9.x core/modules/search/search.module \search_form_search_block_form_alter()
- 10 core/modules/search/search.module \search_form_search_block_form_alter()
- 11.x 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 586
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.