I am using Zend 1.12 and php 5.4.3 and flashMessenger->getMessages() has suddenly stopped working in a controller action.
In AController, a certain type of account is created and it takes 9 steps to create it, so I have 9 actions create1-9Action
On each step I pass the form data to the next step using flashmessenger.
This is the typical structure of an action:
public function create5Action()
{
$form = new My_Form();
$messages = $this->_helper->flashMessenger->getMessages();
$data = $messages[0];
if ($this->_request->isPost())
{
if ($form->isValid($this->_request->getPost()))
{
/* form treatment */
$this->_helper->flashMessenger->addMessage($data);
$this->_redirect($this->_helper->url("create6", "A", null)); // redirect to next step
}
}
$this->_helper->flashMessenger->addMessage($data);
$this->view->form = $form;
}
In this action (create5) the data is intact when arriving from create4Action, it is intact when adding it as a message before $this->view->form = $form;, but when I add new elements to the form and submit it, $messages = $this->_helper->flashMessenger->getMessages(); is null and I do not know why, since it is working for all other actions.
You may have missed adding the
elsein theisPost()loop.However this is not the anticipated use of the flash messenger. I think a part of your problem is that every time a request is made the flash messenger namespace is cleared during the
postDispatch()portion of the dispatch loop.You may be better off using your own Zend_Session_Namespace instance instead of relying on the instance that flash messenger is using.