Difference between #3 and #4 of
An easy way to display a success page using flash messages

Revision #4 has been created by qiang on Apr 12, 2011, 1:10:03 AM with the memo:

Added warning
« previous (#3)

Changes

Title unchanged

An easy way to display a success page using flash messages

Category unchanged

Tips

Yii version unchanged

Tags unchanged

flash message, Forms

Content changed

[...]
* First, instead of saving a string as flash message, we save an array of data that will persist to the next page request.

* Second, we use the action code to control which view to render. The code conforms better to the MVC pattern.

> Note: Flash messages are essentially stored as session data. As a result, they will be serialized when saving and deserialized when loading. For this reason, the data saved as flash message should be simple data, such as strings, numbers. Do not store objects (e.g. data model objects) or resource handles in it because their serialization and deserialization may cause problem.
 
 

## Refactoring the code

If an application needs to display different success pages in different actions, we may refactor the above code so that the usage is even simpler and more DRY.

First in the [base controller class](http://www.yiiframework.com/wiki/121/extending-common-classes-to-allow-better-customization), define the following method:
[...]
21 0
29 followers
Viewed: 57 747 times
Version: 1.1
Category: Tips
Written by: qiang
Last updated by: qiang
Created on: Apr 11, 2011
Last updated: 13 years ago
Update Article

Revisions

View all history