TermForm::validateForm

public TermForm::validateForm(array &$form, FormStateInterface $form_state)

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 94

Class

TermForm
Base for handler for taxonomy term edit forms.

Namespace

Drupal\taxonomy

Code

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.'));
  }
}
doc_Drupal
2016-10-29 09:47:12
Comments
Leave a Comment

Please login to continue.