public function EditComponentForm::moveItemsSubmit in Layout Paragraphs 2.0.x
Moves items from removed regions into designated new ones.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
1 call to EditComponentForm::moveItemsSubmit()
- EditComponentForm::submitForm in src/
Form/ EditComponentForm.php - Saves the paragraph component.
File
- src/
Form/ EditComponentForm.php, line 142
Class
- EditComponentForm
- Class LayoutParagraphsComponentEditForm.
Namespace
Drupal\layout_paragraphs\FormCode
public function moveItemsSubmit(array &$form, FormStateInterface $form_state) {
if ($move_items = $form_state
->getValue([
'layout_paragraphs',
'move_items',
])) {
$section = $this->layoutParagraphsLayout
->getLayoutSection($this->paragraph);
foreach ($move_items as $source => $destination) {
$components = $section
->getComponentsForRegion($source);
foreach ($components as $component) {
$component
->setSettings([
'region' => $destination,
]);
$this->layoutParagraphsLayout
->setComponent($component
->getEntity());
}
}
}
}