public function EditComponentForm::successfulAjaxSubmit in Layout Paragraphs 2.0.x
Allows the form to respond to a successful AJAX submission.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Ajax\AjaxResponse An AJAX response.
Overrides AjaxFormHelperTrait::successfulAjaxSubmit
File
- src/
Form/ EditComponentForm.php, line 62
Class
- EditComponentForm
- Class LayoutParagraphsComponentEditForm.
Namespace
Drupal\layout_paragraphs\FormCode
public function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$this
->ajaxCloseForm($response);
if ($this
->needsRefresh()) {
return $this
->refreshLayout($response);
}
$uuid = $this->paragraph
->uuid();
$rendered_item = $this
->renderParagraph($uuid);
$response
->addCommand(new ReplaceCommand("[data-uuid={$uuid}]", $rendered_item));
$response
->addCommand(new LayoutParagraphsEventCommand($this->layoutParagraphsLayout, $uuid, 'component:update'));
return $response;
}