Zend FlashMessenger

时间:2014-12-06 23:47:45

标签: php zend-framework

遇到问题,不知道为什么会发生这种情况:

首先,一切正常,消息已设置并显示:

$this->_helper->FlashMessenger()
              ->setNamespace('success')
              ->addMessage('Success!')
              ->addMessage('User ' . $this->_request->getPost('user_name') . ' sucessfully added!');
$this->redirect('users/index');

但是,在这种情况下,它失败并显示消息:

  

警告:缺少参数1   Zend_Controller_Action_Helper_FlashMessenger ::直接()

$this->_helper->FlashMessenger()
              ->setNamespace('error')
              ->addMessage('Failure!')
              ->addMessage('User was not added, please see errors below.');

1 个答案:

答案 0 :(得分:0)

尝试将代码更改为:

$this->_helper->getHelper('FlashMessenger')
              ->setNamespace('error')
              ->addMessage('Failure!')
              ->addMessage('User was not added, please see errors below.');