function TestForm::validateForm
Same name in this branch
- 10 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\TestForm::validateForm()
Same name in other branches
- 9 core/modules/block/tests/modules/block_test/src/Form/TestForm.php \Drupal\block_test\Form\TestForm::validateForm()
- 9 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\TestForm::validateForm()
- 8.9.x core/modules/block/tests/modules/block_test/src/Form/TestForm.php \Drupal\block_test\Form\TestForm::validateForm()
- 8.9.x core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\TestForm::validateForm()
- 11.x core/modules/block/tests/modules/block_test/src/Form/TestForm.php \Drupal\block_test\Form\TestForm::validateForm()
- 11.x core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\TestForm::validateForm()
Overrides FormBase::validateForm
File
-
core/
modules/ block/ tests/ modules/ block_test/ src/ Form/ TestForm.php, line 42
Class
- TestForm
- Form that performs base block form test.
Namespace
Drupal\block_test\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!str_contains($form_state->getValue('email'), '.com')) {
$form_state->setErrorByName('email', $this->t('This is not a .com email address.'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.