diff --git a/plugins/Sandbox/src/Controller/AjaxExamplesController.php b/plugins/Sandbox/src/Controller/AjaxExamplesController.php index 7bc5e726..25a2d842 100644 --- a/plugins/Sandbox/src/Controller/AjaxExamplesController.php +++ b/plugins/Sandbox/src/Controller/AjaxExamplesController.php @@ -42,6 +42,9 @@ public function initialize(): void { if (in_array($this->request->getParam('action'), ['redirectingPrevented', 'form', 'toggle', 'editInPlace', 'editInPlaceEmail', 'tableDelete'])) { $this->loadComponent('Ajax.Ajax'); + if ($this->request->getQuery('no-header')) { + $this->Flash->setConfig('noSessionOnAjax', false); + } } $this->viewBuilder()->addHelper('Data.Data'); diff --git a/plugins/Sandbox/templates/AjaxExamples/redirecting_prevented.php b/plugins/Sandbox/templates/AjaxExamples/redirecting_prevented.php index 3db7e63c..a8e89438 100644 --- a/plugins/Sandbox/templates/AjaxExamples/redirecting_prevented.php +++ b/plugins/Sandbox/templates/AjaxExamples/redirecting_prevented.php @@ -74,5 +74,14 @@ +
+ Note:
+ The example above also uses Flash plugin which auto-adds the flash messages as X-Flash
header to the response.
+ If you want to keep the flash messages in the payload, you can also disable the header part using `'noSessionOnAjax'` config set to false (see code).
+ Html->link('Not using header but payload', ['?' => ['no-header' => true]]); ?>
+