function SearchPageForm::submitForm

Same name and namespace in other branches
  1. 9 core/modules/search/src/Form/SearchPageForm.php \Drupal\search\Form\SearchPageForm::submitForm()
  2. 8.9.x core/modules/search/src/Form/SearchPageForm.php \Drupal\search\Form\SearchPageForm::submitForm()
  3. 10 core/modules/search/src/Form/SearchPageForm.php \Drupal\search\Form\SearchPageForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/search/src/Form/SearchPageForm.php, line 87

Class

SearchPageForm
Provides a search form for site wide search.

Namespace

Drupal\search\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    // Redirect to the search page with keywords in the GET parameters.
    // Plugins with additional search parameters will need to provide their
    // own form submit handler to replace this, so they can put their values
    // into the GET as well. If so, make sure to put 'keys' into the GET
    // parameters so that the search results generation is triggered.
    $query = $this->entity
        ->getPlugin()
        ->buildSearchUrlQuery($form_state);
    $route = 'search.view_' . $form_state->get('search_page_id');
    $form_state->setRedirect($route, [], [
        'query' => $query,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.