I wonder if its possible to use flash messenger without redirect? eg. After a failed login, I want to continue to display the form, no redirect required.
public function loginAction() {
$form = new Application_Form_Login();
...
if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
$authAdapter = new Application_Auth_Adapter($form->getValue('username'), $form->getValue('password'));
if ($this->auth->authenticate($authAdapter)->isValid()) {
...
} else {
// login failed
$this->flashMessenger->addMessage('Login failed. You may have entered an invalid username and/or password. Try again');
}
}
$this->view->form = $form;
}
You can retrieve flash messages without redirect using $this->flashMessenger->getCurrentMessages(); Example:
$this->view->messages = array_merge(
$this->_helper->flashMessenger->getMessages(),
$this->_helper->flashMessenger->getCurrentMessages()
);
$this->_helper->flashMessenger->clearCurrentMessages();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With