You are here

public function LayoutChangeSettings::validateForm in Panels 8.4

Same name and namespace in other branches
  1. 8.3 src/Form/LayoutChangeSettings.php \Drupal\panels\Form\LayoutChangeSettings::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/LayoutChangeSettings.php, line 192

Class

LayoutChangeSettings
Provides a form for configuring a layout's settings.

Namespace

Drupal\panels\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $cached_values = $form_state
    ->getTemporaryValue('wizard');

  /* @var $plugin \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant */
  $plugin = $cached_values['plugin'];
  $layout_id = !empty($cached_values['layout_change']['new_layout']) ? $cached_values['layout_change']['new_layout'] : $plugin
    ->getConfiguration()['layout'];
  $layout = $this->manager
    ->createInstance($layout_id, []);
  if ($layout instanceof PluginFormInterface) {
    $sub_form_state = new FormState();
    $plugin_values = $form_state
      ->getValue([
      'layout_settings_wrapper',
      'layout_settings',
    ]);
    if ($plugin_values) {
      $sub_form_state
        ->setValues($plugin_values);
      $layout
        ->validateConfigurationForm($form, $sub_form_state);
    }
  }
}