function SearchHooks::formSearchBlockFormAlter
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/ src/ Hook/ SearchHooks.php, line 114
Class
- SearchHooks
- Hook implementations for search.
Namespace
Drupal\search\HookCode
public function formSearchBlockFormAlter(&$form, FormStateInterface $form_state) : void {
$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.