You are here

public function VariantPluginConfigureBlockFormBase::validateForm in Page Manager 8

Same name and namespace in other branches
  1. 8.4 page_manager_ui/src/Form/VariantPluginConfigureBlockFormBase.php \Drupal\page_manager_ui\Form\VariantPluginConfigureBlockFormBase::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

page_manager_ui/src/Form/VariantPluginConfigureBlockFormBase.php, line 156
Contains \Drupal\page_manager_ui\Form\VariantPluginConfigureBlockFormBase.

Class

VariantPluginConfigureBlockFormBase
Provides a base form for configuring a block as part of a variant.

Namespace

Drupal\page_manager_ui\Form

Code

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

  // The page might have been serialized, resulting in a new variant
  // collection. Refresh the block object.
  $this->block = $this
    ->getVariantPlugin()
    ->getBlock($form_state
    ->get('block_id'));
  $settings = (new FormState())
    ->setValues($form_state
    ->getValue('settings'));

  // Call the plugin validate handler.
  $this->block
    ->validateConfigurationForm($form, $settings);

  // Update the original form values.
  $form_state
    ->setValue('settings', $settings
    ->getValues());
}