Display an error message before redirect to a another page in Zend Framework

178 Views Asked by At

I'm trying to display an error message using flashMessenger and display the message before redirecting to a another page but it does not show up the error message, just do the redirection,

Below is the that i am using in my controller

$this->_helper->flashMessenger->addMessage('this user name is already taken  please choose a another');
$message = $this->_helper->flashMessenger->getCurrentMessages(); 
echo($message[0]);
sleep(5);
$this->_redirect('index/login'); 

can any one tell me why

1

There are 1 best solutions below

0
Nandakumar On
No need of Flash Messenger for this...


Check Username before this.

If Username exists You can set Message on the controller Itself.
Eg. $egForm = new EgForm();
$egForm->get('form_element_name')->setMessages(array('this user name is already taken  please choose a   anoth