public function BlockListingForm::submitForm in Layout Builder Browser 8
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
- src/
Form/ BlockListingForm.php, line 257
Class
- BlockListingForm
- Builds a listing of block entities.
Namespace
Drupal\layout_builder_browser\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$blocks = $form_state
->getValue('categories');
$lb_block_storage = $this->entityTypeManager
->getStorage('layout_builder_browser_block');
foreach ($blocks as $id => $block) {
$lb_block = $lb_block_storage
->load($id);
$lb_block->weight = $block['weight'];
$lb_block->category = $block['category'];
$lb_block
->save();
}
$this
->messenger()
->addMessage($this
->t('The blocks have been updated.'));
}