You are here

public function SearchApiPageBlockForm::submitForm in Search API Pages 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/SearchApiPageBlockForm.php, line 170

Class

SearchApiPageBlockForm
Builds the search form for the search api page block.

Namespace

Drupal\search_api_page\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // This form submits to the search page, so processing happens there.
  $langcode = $this->languageManager
    ->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
    ->getId();
  $route = 'search_api_page.' . $langcode . '.' . $form_state
    ->getValue('search_api_page');
  $routeArguments = [
    'keys' => $form_state
      ->getValue('keys'),
  ];
  $form_state
    ->setRedirectUrl(Url::fromRoute($route, $routeArguments));
}