You are here

public function MessageNotifyUiSenderMailSettingsForm::validate in Message UI 8

Validating the form.

Parameters

array $form: The form API element.

\Drupal\Core\Form\FormStateInterface $formState: The form state object.

Overrides MessageNotifyUiSenderSettingsFormBase::validate

File

modules/message_notify_ui/src/Plugin/MessageNotifyUiSenderSettingsForm/MessageNotifyUiSenderMailSettingsForm.php, line 47

Class

MessageNotifyUiSenderMailSettingsForm
Message notify plugin form for email.

Namespace

Drupal\message_notify_ui\Plugin\MessageNotifyUiSenderSettingsForm

Code

public function validate(array $form, FormStateInterface $formState) {
  if ($formState
    ->getValue('use_custom') && !$formState
    ->getValue('email')) {
    $formState
      ->setErrorByName('email', t('The email field cannot be empty.'));
  }
}