public function ManageComponentAttributesForm::submitForm in Layout Builder Component Attributes 1.0.x
Same name and namespace in other branches
- 1.2.x src/Form/ManageComponentAttributesForm.php \Drupal\layout_builder_component_attributes\Form\ManageComponentAttributesForm::submitForm()
- 1.1.x src/Form/ManageComponentAttributesForm.php \Drupal\layout_builder_component_attributes\Form\ManageComponentAttributesForm::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
- src/
Form/ ManageComponentAttributesForm.php, line 405
Class
- ManageComponentAttributesForm
- Provides a form for managing block attributes.
Namespace
Drupal\layout_builder_component_attributes\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$delta = $this
->getSelectedDelta($form_state);
$section = $this->sectionStorage
->getSection($delta);
$values = $form_state
->getValues();
$additional_settings = [
'block_attributes' => [
'id' => $values['block_attributes']['id'] ?? '',
'class' => $values['block_attributes']['class'] ?? '',
'style' => $values['block_attributes']['style'] ?? '',
'data' => $values['block_attributes']['data'] ?? '',
],
'block_title_attributes' => [
'id' => $values['block_title_attributes']['id'] ?? '',
'class' => $values['block_title_attributes']['class'] ?? '',
'style' => $values['block_title_attributes']['style'] ?? '',
'data' => $values['block_title_attributes']['data'] ?? '',
],
'block_content_attributes' => [
'id' => $values['block_content_attributes']['id'] ?? '',
'class' => $values['block_content_attributes']['class'] ?? '',
'style' => $values['block_content_attributes']['style'] ?? '',
'data' => $values['block_content_attributes']['data'] ?? '',
],
];
// Store configuration in layout_builder.component.additional.
// Switch to third-party settings when
// https://www.drupal.org/project/drupal/issues/3015152 is committed.
$section
->getComponent($this->uuid)
->set('component_attributes', $additional_settings);
$this->layoutTempstore
->set($this->sectionStorage);
$form_state
->setRedirectUrl($this->sectionStorage
->getLayoutBuilderUrl());
}