public function GoogleCSESearch::searchFormAlter in Google Custom Search Engine 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/Search/GoogleCSESearch.php \Drupal\google_cse\Plugin\Search\GoogleCSESearch::searchFormAlter()
Alters the search form when being built for a given plugin.
The core search module only invokes this method on active module plugins when building a form for them in \Drupal\search\Form\SearchPageForm::buildForm(). A plugin implementing this will also need to implement the buildSearchUrlQuery() method.
Parameters
array $form: Nested array of form elements that comprise the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. The arguments that \Drupal::formBuilder()->getForm() was originally called with are available in the array $form_state->getBuildInfo()['args'].
Overrides SearchPluginBase::searchFormAlter
See also
SearchInterface::buildSearchUrlQuery()
File
- src/
Plugin/ Search/ GoogleCSESearch.php, line 235
Class
- GoogleCSESearch
- Handles searching for node entities using the Search module index.
Namespace
Drupal\google_cse\Plugin\SearchCode
public function searchFormAlter(array &$form, FormStateInterface $form_state) {
// Adds custom submit handler for search form.
if ($this->pluginId == 'google_cse_search') {
$this->googlecseservices
->siteSearchForm($form);
$form['#attributes']['class'][] = 'google-cse';
}
}