/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $display_variant_id = NULL, $block_id = NULL) { $this->page = $page; $this->displayVariant = $this->page->getVariant($display_variant_id); $this->block = $this->displayVariant->getBlock($block_id); return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { // The page might have been serialized, resulting in a new display variant // collection. Refresh the display variant and block objects. $this->displayVariant = $this->page->getVariant($form_state->get('display_variant_id')); $this->block = $this->displayVariant->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()); }