You are here

public function HtmlMailConfigurationForm::validateForm in HTML Mail 8.3

Same name and namespace in other branches
  1. 8 src/Form/HtmlMailConfigurationForm.php \Drupal\htmlmail\Form\HtmlMailConfigurationForm::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/HtmlMailConfigurationForm.php, line 313

Class

HtmlMailConfigurationForm
Class HtmlMailConfigurationForm.

Namespace

Drupal\htmlmail\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('use_mail_mime')) {

    // Try including the files, then check for the classes.
    if (!class_exists('\\Mail_mime') || !class_exists('\\Mail_mimeDecode') || !class_exists('\\Mail_mimePart')) {
      $form_state
        ->setErrorByName('use_mail_mime', $this
        ->t('The \\Mail_mime class was not found. Please download the required class using the <a href="@help">help section</a> commands or disable the option.', [
        '@help' => '/admin/help/htmlmail',
      ]));
    }
  }
  parent::validateForm($form, $form_state);
}