public function DbtngExampleUpdateForm::validateForm in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/dbtng_example/src/Form/DbtngExampleUpdateForm.php \Drupal\dbtng_example\Form\DbtngExampleUpdateForm::validateForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- dbtng_example/
src/ Form/ DbtngExampleUpdateForm.php, line 153
Class
- DbtngExampleUpdateForm
- Sample UI to update a record.
Namespace
Drupal\dbtng_example\FormCode
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'));
}
}