function EntityAutocomplete::validateForm
Same name in other branches
- 8.x-1.x ajax_example/src/Form/EntityAutocomplete.php \Drupal\ajax_example\Form\EntityAutocomplete::validateForm()
- 4.0.x modules/ajax_example/src/Form/EntityAutocomplete.php \Drupal\ajax_example\Form\EntityAutocomplete::validateForm()
Here we validate and signal an error if there are no users selected.
Overrides FormInterface::validateForm
File
-
modules/
ajax_example/ src/ Form/ EntityAutocomplete.php, line 105
Class
- EntityAutocomplete
- A simple autocomplete form which looks up usernames.
Namespace
Drupal\ajax_example\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$state_users = $form_state->getValue('users');
if (empty($state_users)) {
$form_state->setErrorByName('users', 'There were no users selected.');
}
}