You are here

public function PetPreviewForm::validateForm in Previewable email templates 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/PetPreviewForm.php \Drupal\pet\Form\PetPreviewForm::validateForm()
  2. 8 src/Form/PetPreviewForm.php \Drupal\pet\Form\PetPreviewForm::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

src/Form/PetPreviewForm.php, line 259

Class

PetPreviewForm
PetPreviewForm.

Namespace

Drupal\pet\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getStorage()['step'] == 1) {
    $recipients_array = [];

    // todo: Make this more generic, and also test CC and BCC input.
    $errors = $this
      ->validateRecipients($form_state, $recipients_array);
    if (!empty($errors)) {
      foreach ($errors as $error) {
        $form_state
          ->setErrorByName('recipients', $error);
      }
    }
    else {
      $form_state
        ->setValue('recipients_array', $recipients_array);
    }
  }
}