You are here

public function LiveResults::submitConfigurationForm in Search API Autocomplete 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

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

Overrides PluginFormTrait::submitConfigurationForm

See also

\Drupal\Core\Plugin\PluginFormInterface::submitConfigurationForm()

File

src/Plugin/search_api_autocomplete/suggester/LiveResults.php, line 270

Class

LiveResults
Provides a suggester plugin that displays live results.

Namespace

Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\suggester

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();

  // Change the "fields" option to an array of just the selected fields.
  $values['fields'] = array_keys(array_filter($values['fields']));

  // Cast to bool to prevent schema mismatches.
  $values['highlight']['enabled'] = (bool) $values['highlight']['enabled'];
  $this
    ->setConfiguration($values);
}