You are here

public function ConfigureBlockFormBase::submitForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php \Drupal\layout_builder\Form\ConfigureBlockFormBase::submitForm()

Form submission 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 FormInterface::submitForm

File

core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php, line 219

Class

ConfigureBlockFormBase
Provides a base form for configuring a block.

Namespace

Drupal\layout_builder\Form

Code

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

  // Call the plugin submit handler.
  $subform_state = SubformState::createForSubform($form['settings'], $form, $form_state);
  $this
    ->getPluginForm($this->block)
    ->submitConfigurationForm($form, $subform_state);

  // If this block is context-aware, set the context mapping.
  if ($this->block instanceof ContextAwarePluginInterface) {
    $this->block
      ->setContextMapping($subform_state
      ->getValue('context_mapping', []));
  }
  $configuration = $this->block
    ->getConfiguration();
  $section = $this->sectionStorage
    ->getSection($this->delta);
  $section
    ->getComponent($this->uuid)
    ->setConfiguration($configuration);
  $this->layoutTempstoreRepository
    ->set($this->sectionStorage);
  $form_state
    ->setRedirectUrl($this->sectionStorage
    ->getLayoutBuilderUrl());
}