Skip to content

Commit

Permalink
Document messages in payload.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Apr 17, 2024
1 parent ddb90a3 commit da059eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/Sandbox/src/Controller/AjaxExamplesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,14 @@
</div>
</div>

<hr>

<p>
Note:
The example above also uses Flash plugin which auto-adds the flash messages as <code>X-Flash</code> 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).
<?php echo $this->Html->link('Not using header but payload', ['?' => ['no-header' => true]]); ?>
</p>

</div>

0 comments on commit da059eb

Please sign in to comment.