You are here

public function LayoutParagraphsBuilderForm::submitForm in Layout Paragraphs 2.0.x

Saves the layout to its parent entity.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

Overrides FormInterface::submitForm

File

src/Form/LayoutParagraphsBuilderForm.php, line 158

Class

LayoutParagraphsBuilderForm
Class LayoutParagraphsBuilderForm.

Namespace

Drupal\layout_paragraphs\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $entity = $this->layoutParagraphsLayout
    ->getEntity();
  $field_name = $this->layoutParagraphsLayout
    ->getFieldName();
  $entity->{$field_name} = $this->layoutParagraphsLayout
    ->getParagraphsReferenceField();
  $entity
    ->save();
  $this->layoutParagraphsLayout
    ->setParagraphsReferenceField($entity->{$field_name});
  $this->tempstore
    ->set($this->layoutParagraphsLayout);
}