function EmailAction::validateConfigurationForm

Same name in other branches
  1. 9 core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php \Drupal\Core\Action\Plugin\Action\EmailAction::validateConfigurationForm()
  2. 8.9.x core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php \Drupal\Core\Action\Plugin\Action\EmailAction::validateConfigurationForm()
  3. 11.x core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php \Drupal\Core\Action\Plugin\Action\EmailAction::validateConfigurationForm()

Overrides ConfigurableActionBase::validateConfigurationForm

File

core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php, line 193

Class

EmailAction
Sends an email message.

Namespace

Drupal\Core\Action\Plugin\Action

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    if (!$this->emailValidator
        ->isValid($form_state->getValue('recipient')) && !str_contains($form_state->getValue('recipient'), ':mail')) {
        // We want the literal %author placeholder to be emphasized in the error message.
        $form_state->setErrorByName('recipient', $this->t('Enter a valid email address or use a token email address such as %author.', [
            '%author' => '[node:author:mail]',
        ]));
    }
}

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