function DbtngExampleUpdateForm::validateForm

Same name in other branches
  1. 4.0.x modules/dbtng_example/src/Form/DbtngExampleUpdateForm.php \Drupal\dbtng_example\Form\DbtngExampleUpdateForm::validateForm()

Overrides FormBase::validateForm

File

modules/dbtng_example/src/Form/DbtngExampleUpdateForm.php, line 153

Class

DbtngExampleUpdateForm
Sample UI to update a record.

Namespace

Drupal\dbtng_example\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    // Confirm that age is numeric.
    if (!intval($form_state->getValue('age'))) {
        $form_state->setErrorByName('age', $this->t('Age needs to be a number'));
    }
}