public function SuggestionEditForm::validateForm in Autocomplete Search Suggestions 8.2
Same name and namespace in other branches
- 8 src/Form/SuggestionEditForm.php \Drupal\suggestion\Form\SuggestionEditForm::validateForm()
- 3.0.x src/Form/SuggestionEditForm.php \Drupal\suggestion\Form\SuggestionEditForm::validateForm()
Validation function for the suggestion edit form.
Parameters
array $form: A drupal form array.
\Drupal\Core\Form\FormStateInterface $form_state: A Drupal FormStateInterface object.
Overrides FormBase::validateForm
File
- src/
Form/ SuggestionEditForm.php, line 128
Class
- SuggestionEditForm
- Suggestion indexing form.
Namespace
Drupal\suggestion\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!is_numeric(trim($form_state
->getValue('qty')))) {
$form_state
->setErrorByName('qty', $this
->t('The quantity must have a numeric value'));
}
if (!count((array) $form_state
->getValue('src'))) {
$form_state
->setErrorByName('src', $this
->t('The source must have a value.'));
}
elseif (isset($form_state
->getValue('src')[0]) && count((array) $form_state
->getValue('src')) > 1) {
$form_state
->setErrorByName('src', $this
->t('The disabled option cannot be combined with other options.'));
}
}