public function DeleteComponentForm::deleteComponent in Layout Paragraphs 2.0.x
Ajax callback - deletes component and closes the form.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
File
- src/
Form/ DeleteComponentForm.php, line 111
Class
- DeleteComponentForm
- Class DeleteComponentForm.
Namespace
Drupal\layout_paragraphs\FormCode
public function deleteComponent(array $form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response
->addCommand(new CloseDialogCommand($this
->dialogSelector($this->layoutParagraphsLayout)));
if ($this
->needsRefresh()) {
return $this
->refreshLayout($response);
}
$response
->addCommand(new RemoveCommand('[data-uuid="' . $this->componentUuid . '"]'));
$response
->addCommand(new LayoutParagraphsEventCommand($this->layoutParagraphsLayout, $this->componentUuid, 'component:delete'));
return $response;
}