Feedback messages to the user

How are u guys doing with feedback messages to the user?

For example, after saving some info to the database, how are you doing to show an "Information saved successfully" message to the user?

Can you post some snipets?

You may use the "flash" feature, like the following:


// controller part

public function actionUpdate()


	if(model saved)


		Yii::app()->user->setFlash('updateSuccess','data saved successfully');






// view part

<?php if(Yii::app()->user->hasFlash('updateSuccess')): ?>

<?php echo Yii::app()->user->getFlash('updateSuccess'); ?>

<?php else: ?> the form here...

<?php endif; ?>

I think I would use a session variable.  Store the message in the session and then in the view (or even better the layout) check for the session variable, and if it exists, show it and than destroy it.

Yes, that's what "flash" does. The message will be discarded after it is displayed once. Therefore, if you refresh the page again, the message will disappear.

Oh, so Yii does have flash methods… wasn't able to find any…

Thank you folks!