Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It works exactly like it should, this is the intended behavior of FlashMessenger helper.
What FlashMessenger does is store the messages you add in session. It only loads them from the session upon constructing a new FlashMessenger object; that is when the next request occurs. This is the whole point of FlashMessenger; to pass messages from one request to the another; not to pass messages within the same request (for that, you just use regular variables, or storage such as
Zend_Registry).What you usually do with FlashMessenger is that you first add a message, and you then redirect to the same (or another) page, using eg. the _redirect method, or the Redirector action helper. It’s convenient to subclass the Zend_Controller class, and add your own helper method that lets you do both of these in single method, such as a method called _flash. For instance I usually do something like this:
I then simply do
$this->_flash("My message");which will do two things: 1) Add the message to the flash message stack and 2) Refresh the page.You can also see that I have a
protected $_messages, the reason for this is that if I want to display a message without having to refresh the page, I can simply append a message to that array.