You are here

public function HtmlMailConfigurationForm::validateForm in HTML Mail 8

Same name and namespace in other branches
  1. 8.3 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 300

Class

HtmlMailConfigurationForm
Class HtmlMailConfigurationForm.

Namespace

Drupal\htmlmail\Form

Code

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

    // Try including the files, then cleck for the classes.
    @(include_once 'Edu/Mail/mime.php');
    @(include_once 'Edu/Mail/mimeDecode.php');
    @(include_once 'Edu/Mail/mimePart.php');
    if (!class_exists('Mail_Mime') || !class_exists('Mail_mimeDecode') || !class_exists('Mail_mimePart')) {
      $form_state
        ->setErrorByName('htmlmail_use_mime_mail', $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);
}