public function LayoutParagraphsBuilderForm::save in Layout Paragraphs 2.0.x
Ajax callback.
Displays a message when the entity is saved.
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 138
Class
- LayoutParagraphsBuilderForm
- Class LayoutParagraphsBuilderForm.
Namespace
Drupal\layout_paragraphs\FormCode
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->layoutParagraphsLayout
->getEntity();
$response = new AjaxResponse();
$t_args = [
'@type' => $entity
->getEntityType()
->getLabel(),
'%title' => $entity
->toLink()
->toString(),
];
$response
->addCommand(new MessageCommand($this
->t('@type %title has been updated.', $t_args)));
$response
->addCommand(new ReplaceCommand('[data-lpb-form-id="' . $form['#attributes']['data-lpb-form-id'] . '"]', $form));
return $response;
}