You are here

public function SettingsForm::validateForm in Entity Print 8

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsForm.php \Drupal\entity_print\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 181

Class

SettingsForm
Defines a form that configures Entity Print settings.

Namespace

Drupal\entity_print\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  if ($plugin_id = $form_state
    ->getValue('pdf_engine')) {

    // Load the config entity, submit the relevant plugin form and then save
    // it.
    $entity = $this
      ->loadConfigEntity($plugin_id);

    /** @var \Drupal\entity_print\Plugin\PdfEngineInterface $plugin */
    $plugin = $entity
      ->getPdfEnginePluginCollection()
      ->get($entity
      ->id());
    $plugin
      ->validateConfigurationForm($form, $form_state);
  }
}