CakePHP desktop

I had the following problem with setFlash() in my CakePHP application.

CakePHP makes the basic CRUD workflow pretty easy to achieve. However, the following situation arose in the application I am 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: http://stackoverflow.com/a/10115915/4779449 – simply place the following code in your AppController
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.

Leave a Reply

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