You are here

public function TestForm::validateForm in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\TestForm::validateForm()
  2. 10 core/modules/block/tests/modules/block_test/src/Form/TestForm.php \Drupal\block_test\Form\TestForm::validateForm()
Same name and namespace in other branches
  1. 8 core/modules/block/tests/modules/block_test/src/Form/TestForm.php \Drupal\block_test\Form\TestForm::validateForm()
  2. 9 core/modules/block/tests/modules/block_test/src/Form/TestForm.php \Drupal\block_test\Form\TestForm::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

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\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (strpos($form_state
    ->getValue('email'), '.com') === FALSE) {
    $form_state
      ->setErrorByName('email', $this
      ->t('This is not a .com email address.'));
  }
}