You are here

public function FacetsSummaryForm::validateForm in Facets 8

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

modules/facets_summary/src/Form/FacetsSummaryForm.php, line 338

Class

FacetsSummaryForm
Provides a form for configuring the processors of a facet.

Namespace

Drupal\facets_summary\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  /** @var \Drupal\facets_summary\FacetsSummaryInterface $facets_summary */
  $facets_summary = $this->entity;
  $values = $form_state
    ->getValues();

  /** @var \Drupal\facets_summary\Processor\ProcessorInterface[] $processors */
  $processors = $facets_summary
    ->getProcessors(FALSE);

  // Iterate over all processors that have a form and are enabled.
  foreach ($form['facets_summary_settings'] as $processor_id => $processor_form) {
    if (!empty($values['processors'][$processor_id])) {
      $processor_form_state = SubformState::createForSubform($form['facets_summary_settings'][$processor_id]['settings'], $form, $form_state);
      $processors[$processor_id]
        ->validateConfigurationForm($form['facets_summary_settings'][$processor_id], $processor_form_state, $facets_summary);
    }
  }
}