public function TermForm::validateForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::validateForm()
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level validation handler, otherwise an exception will be thrown.
Overrides ContentEntityForm::validateForm
File
- core/
modules/ taxonomy/ src/ TermForm.php, line 132
Class
- TermForm
- Base for handler for taxonomy term edit forms.
Namespace
Drupal\taxonomyCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
// Ensure numeric values.
if ($form_state
->hasValue('weight') && !is_numeric($form_state
->getValue('weight'))) {
$form_state
->setErrorByName('weight', $this
->t('Weight value must be numeric.'));
}
}