CakePHP desktop

CakePHP makes the basic CRUD workflow pretty easy to achieve. However, the following situation arose with setFlash() in the CakePHP application I was building at work:

  1. I have a page which list things, and which includes an edit button
  2. upon clicking the edit button, editing the thing, and submitting the update, the controller routes me back to the list view
  3. a setFlash() message is displayed confirming success or failure
  4. if I click then click on the edit link (of any of the things in the list), but then click cancel or the back button in the edit view (after starting to make changes or not), the setFlash() message is still displayed on the list view, making it look like the thing was successfully edited
  5. I found the solution here: — simply place the following code in your AppController
// this is to remove Flash messages where you use the browser back button or js back button
	public function beforeRender() {

This seems a bit like overkill as my understanding is that this will disable the cache entirely for all pages. What I am really looking for is a way to clear the stale message.

By foxbeefly

PHP / MySQL Developer. HTML, CSS and some JavaScript.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.