Hi.

I'm trying to use flashMessenger, but interface it provides is a bit
unhandy, because messages cannot be retreived by id, you can get only array
of messages and thats all.

For example, I only need to detect success after sending email on my contact
page, and show some message to user if email is sent:

class ContactController extends Zend_Controller_Action {
    public function indexAction() {
                $this->view->form = new Form_Contact();
                $this->view->sent = false;
                if ($this->_helper->flashMessenger->hasMessages()) {
                        $this->view->sent =
array_pop($this->_helper->flashMessenger->getMessages());
                }
    }
    public function sendAction() {
                $form = new Form_Contact();
                if ($form->isValid($_POST)) {
                        // TODO: send
                        $this->_helper->flashMessenger(true);
                        $this->_helper->redirector->gotoRoute(array('action' => 
'index'));
                } else {
                        $this->view->form = $form;
                        $this->render('index');
                }
    }
}

So, I pop here this flag (message) which is true if email is sent.

This works, but, is there a simpler way to get flag I previously set?
And, I see that hops is set to 1
 self::$_session->setExpirationHops(1, null, true);
this means that if I get messages once, and use just one of them, all will
be deleted?

Regards,
Saša Stamenković.
-- 
View this message in context: 
http://n4.nabble.com/flashMessenger-a-bit-hard-to-use-tp978447p978447.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to