diff --git a/config/bolt/config.yaml b/config/bolt/config.yaml index cda65ef9f..adb5627ad 100644 --- a/config/bolt/config.yaml +++ b/config/bolt/config.yaml @@ -253,3 +253,6 @@ reset_password_settings: # Adds sorting and filtering of users in backend user_show_sort&filter: true + +# Use Ajaxy saving ("Stay on page"), or traditional saving +ajaxy_saving: true diff --git a/src/Controller/Backend/ContentEditController.php b/src/Controller/Backend/ContentEditController.php index d5f2f9bfd..787f7b2ae 100644 --- a/src/Controller/Backend/ContentEditController.php +++ b/src/Controller/Backend/ContentEditController.php @@ -219,15 +219,23 @@ public function save(?Content $originalContent = null, ?ContentValidatorInterfac $locale = $originalAuthor->getLocale(); - return new JsonResponse([ - 'url' => $url, - 'status' => 'success', - 'type' => $this->translator->trans('success', [], null, $locale), - 'message' => $this->translator->trans('content.updated_successfully', [], null, $locale), - 'notification' => $this->translator->trans('flash_messages.notification', [], null, $locale), - 'title' => $content->getExtras()['title'], - ], 200 - ); + // If we're "Saving Ajaxy" + if ($this->request->isXmlHttpRequest()) { + return new JsonResponse([ + 'url' => $url, + 'status' => 'success', + 'type' => $this->translator->trans('success', [], null, $locale), + 'message' => $this->translator->trans('content.updated_successfully', [], null, $locale), + 'notification' => $this->translator->trans('flash_messages.notification', [], null, $locale), + 'title' => $content->getExtras()['title'], + ], 200 + ); + } + + // Otherwise, treat it as a normal POST-request cycle.. + $this->addFlash('success', 'content.updated_successfully'); + + return new RedirectResponse($url); } /** diff --git a/templates/content/_buttons.html.twig b/templates/content/_buttons.html.twig index 87cf1fbda..ab994c281 100644 --- a/templates/content/_buttons.html.twig +++ b/templates/content/_buttons.html.twig @@ -2,7 +2,14 @@