You are here

public function CustomScript::validateConfigurationForm in Search API Autocomplete 8

Form validation 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::validateConfigurationForm

See also

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

File

src/Plugin/search_api_autocomplete/suggester/CustomScript.php, line 63

Class

CustomScript
Uses a custom (non-Drupal) script for generating autocomplete suggestions.

Namespace

Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\suggester

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('path', '') === '') {
    $args = [
      '%field' => $form['path']['#title'],
    ];
    $message = $this
      ->t('The %field field is required.', $args);
    $form_state
      ->setError($form['path'], $message);
  }
}