You are here

protected function SimpleSearchForm::setupSearchApiAutocomplete in Simple search form 8

Setup Search API Autocomplete for requested form.

Parameters

array $form: Form to setup Search API Autocomplete.

array $config: Block configuration.

1 call to SimpleSearchForm::setupSearchApiAutocomplete()
SimpleSearchForm::buildForm in src/Form/SimpleSearchForm.php
Form constructor.

File

src/Form/SimpleSearchForm.php, line 99

Class

SimpleSearchForm
SimpleSearchForm definition.

Namespace

Drupal\simple_search_form\Form

Code

protected function setupSearchApiAutocomplete(array &$form, array $config) {
  $autocomplete_config = $config['search_api_autocomplete'];
  $arguments = explode(',', $autocomplete_config['arguments']);
  $arguments = array_map('trim', $arguments);

  // Setup search_api_autocomplete field type, see
  // \Drupal\search_api_autocomplete\Utility\AutocompleteHelper
  // method alterElement() for more details.
  $form[$config['get_parameter']]['#search_id'] = $autocomplete_config['search_id'];
  $form[$config['get_parameter']]['#additional_data'] = [
    'filter' => $autocomplete_config['filter'],
    'display' => $autocomplete_config['display'],
    'arguments' => $arguments,
  ];
}