public function LayoutParagraphsBuilderForm::close in Layout Paragraphs 2.0.x
Ajax callback.
Closes the builder and returns the rendered layout.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
\Drupal\Core\Ajax\AjaxResponse An ajax command.
File
- src/
Form/ LayoutParagraphsBuilderForm.php, line 116
Class
- LayoutParagraphsBuilderForm
- Class LayoutParagraphsBuilderForm.
Namespace
Drupal\layout_paragraphs\FormCode
public function close(array $form, FormStateInterface $form_state) {
$this->tempstore
->delete($this->layoutParagraphsLayout);
$view_mode = $this->layoutParagraphsLayout
->getSetting('reference_field_view_mode', 'default');
$rendered_layout = $this->layoutParagraphsLayout
->getParagraphsReferenceField()
->view($view_mode);
$response = new AjaxResponse();
$response
->addCommand(new ReplaceCommand('[data-lpb-form-id="' . $form['#attributes']['data-lpb-form-id'] . '"]', $rendered_layout));
return $response;
}