public function TextExtractorFormSettings::validateForm in Search API attachments 8
Same name and namespace in other branches
- 9.0.x src/Form/TextExtractorFormSettings.php \Drupal\search_api_attachments\Form\TextExtractorFormSettings::validateForm()
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/ TextExtractorFormSettings.php, line 119
Class
- TextExtractorFormSettings
- Configuration form.
Namespace
Drupal\search_api_attachments\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config(static::CONFIGNAME);
// If it is from the configuration.
$extractor_plugin_id = $form_state
->getValue('extraction_method');
if ($extractor_plugin_id) {
$configuration = $config
->get($extractor_plugin_id . '_configuration');
$extractor_plugin = $this
->getTextExtractorPluginManager()
->createInstance($extractor_plugin_id, $configuration);
// Validate the text_extractor_config part of the form only if it
// corresponds to the current $extractor_plugin_id.
if (!empty($form['text_extractor_config']['extraction_method']['#value']) && $form['text_extractor_config']['extraction_method']['#value'] == $extractor_plugin_id) {
$extractor_plugin
->validateConfigurationForm($form, $form_state);
}
}
}