You are here

public function SettingsForm::validateForm in PHPMailer SMTP 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/SettingsForm.php \Drupal\phpmailer_smtp\Form\SettingsForm::validateForm()
  2. 2.x src/Form/SettingsForm.php \Drupal\phpmailer_smtp\Form\SettingsForm::validateForm()
  3. 2.1.x src/Form/SettingsForm.php \Drupal\phpmailer_smtp\Form\SettingsForm::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/SettingsForm.php, line 303

Class

SettingsForm
Defines a form to configure PHPMailer SMTP settings.

Namespace

Drupal\phpmailer_smtp\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (intval($form_state
    ->getValue('smtp_port') == 0)) {
    $form_state
      ->setErrorByName('smtp_port', $this
      ->t('You must enter a valid SMTP port number.'));
  }
  parent::validateForm($form, $form_state);
}