function MoveBlockForm::submitForm

Same name in other branches
  1. 9 core/modules/layout_builder/src/Form/MoveBlockForm.php \Drupal\layout_builder\Form\MoveBlockForm::submitForm()
  2. 8.9.x core/modules/layout_builder/src/Form/MoveBlockForm.php \Drupal\layout_builder\Form\MoveBlockForm::submitForm()
  3. 11.x core/modules/layout_builder/src/Form/MoveBlockForm.php \Drupal\layout_builder\Form\MoveBlockForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/layout_builder/src/Form/MoveBlockForm.php, line 250

Class

MoveBlockForm
Provides a form for moving a block.

Namespace

Drupal\layout_builder\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $region = $this->getSelectedRegion($form_state);
    $delta = $this->getSelectedDelta($form_state);
    $original_section = $this->sectionStorage
        ->getSection($this->delta);
    $component = $original_section->getComponent($this->uuid);
    $section = $this->sectionStorage
        ->getSection($delta);
    if ($delta !== $this->delta) {
        // Remove component from old section and add it to the new section.
        $original_section->removeComponent($this->uuid);
        $section->insertComponent(0, $component);
    }
    $component->setRegion($region);
    foreach ($form_state->getValue('components') as $uuid => $component_info) {
        $section->getComponent($uuid)
            ->setWeight($component_info['weight']);
    }
    $this->layoutTempstore
        ->set($this->sectionStorage);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.