function 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\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.'));
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.