public function SearchEditForm::validateForm in Search API Autocomplete 8
Form validation 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 FormBase::validateForm
File
- src/
Form/ SearchEditForm.php, line 306
Class
- SearchEditForm
- Provides an edit form for autocomplete search entities.
Namespace
Drupal\search_api_autocomplete\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$values =& $form_state
->getValues();
// Iterate over all suggesters that have a form and are enabled.
$available_suggesters = $this
->getAvailableSuggesters();
$enabled_suggesters = array_keys(array_filter($values['suggesters']['enabled']));
foreach ($enabled_suggesters as $suggester_id) {
$suggester = $available_suggesters[$suggester_id];
if ($suggester instanceof PluginFormInterface) {
$suggester_form_state = SubformState::createForSubform($form['suggesters']['settings'][$suggester_id], $form, $form_state);
$suggester
->validateConfigurationForm($form['suggesters']['settings'][$suggester_id], $suggester_form_state);
}
}
$search_plugin = $this->entity
->getSearchPlugin();
if ($search_plugin instanceof PluginFormInterface) {
$plugin_form_state = SubFormState::createForSubform($form['search_settings'], $form, $form_state);
$search_plugin
->validateConfigurationForm($form['search_settings'], $plugin_form_state);
}
}