You are here

public function SettingsForm::validateForm in Entity Print 8.2

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

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);
  foreach ($this->exportTypeManager
    ->getDefinitions() as $export_type => $definition) {
    if ($plugin_id = $form_state
      ->getValue($export_type)) {

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

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