3 namespace Drupal\block_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Form that performs base block form test.
13 class TestForm extends FormBase {
18 public function getFormId() {
19 return 'block_test_form_test';
25 public function buildForm(array $form, FormStateInterface $form_state) {
28 '#title' => $this->t('Your .com email address.'),
33 '#value' => $this->t('Submit'),
42 public function validateForm(array &$form, FormStateInterface $form_state) {
43 if (strpos($form_state->getValue('email'), '.com') === FALSE) {
44 $form_state->setErrorByName('email', $this->t('This is not a .com email address.'));
51 public function submitForm(array &$form, FormStateInterface $form_state) {
52 $this->messenger()->addStatus($this->t('Your email address is @email', ['@email' => $form['email']['#value']]));