You are here

public function PetPreviewForm::validateForm in Previewable email templates 8.4

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

Class

PetPreviewForm

Namespace

Drupal\pet\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $recipients_raw = $form_state
    ->getValue('recipients');
  $recipients = [];
  $errors = $this
    ->pet_validate_recipients($form_state, $recipients);
  if (!empty($errors)) {
    foreach ($errors as $error) {
      $form_state
        ->setErrorByName('recipients', $error);
    }
  }
  else {
    $form_state
      ->setValue('recipients', $recipients);
    $form_state
      ->setValue('recipients_raw', $recipients_raw);
  }
}