You are here

public function LayoutPluginSelector::validateForm in Panels 8.3

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

Class

LayoutPluginSelector
Provides a form for selecting a layout plugin.

Namespace

Drupal\panels\Form

Code

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

  /* @var $variant_plugin \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant */
  $variant_plugin = $cached_values['plugin'];
  if ((string) $form_state
    ->getValue('op') == $this
    ->t('Change Layout') && $variant_plugin
    ->getConfiguration()['layout'] == $form_state
    ->getValue('layout')) {
    $form_state
      ->setErrorByName('layout', $this
      ->t('You must select a different layout if you wish to change layouts.'));
  }
  if ($form['update_layout']['#access'] && $variant_plugin
    ->getConfiguration()['layout'] != $form_state
    ->getValue('layout') && $form_state
    ->getValue('op') != $form['update_layout']['#value']) {
    $form_state
      ->setErrorByName('layout', $this
      ->t('To select a different layout, you must click "Change Layout".'));
  }
}