现在我的ChildFamily
控制器中有以下方法:
public function statusAction(){
$form = new AddChildForm("add");
$view = array( 'form'=>$form );
$familyId = $this->params()->fromRoute("id");
$error = $this->params();
// If POST, add child to family
$request = $this->getRequest();
if ($request->isPost()) {
$form->setData($request->getPost()->toArray());
if ($form->isValid()) {
try {
$data = $form->getData();
// Clean data
$childId = intval(trim($data[AddChildForm::KEY_CHILD_ID]));
// Add child to the currently displayed family
$cf = new ChildFamily();
$error = $cf->addChildToFamily($familyId, $childId);
if ($error) {
}
// Reload page to update childlist
return $this->redirect()->toRoute('family', array('action' => 'status', 'id' => $familyId, 'error' => $error ));
} catch (\Exception $e) {
$p = $e->getPrevious();
if (is_null($p)) {
$p = $e;
}
$view['error'] = "Error code [ " . $p->getCode() . " ] : " . $p->getMessage() . "<br/><pre>"
. $e->getTraceAsString() . "</pre>";
}
}
}
我想在重定向后使$error
可用。我尝试将其传递到数组中(如上所示),但似乎我无法访问它。有一个更好的方法吗?如果可能的话,我不希望错误的值在路径中。
答案 0 :(得分:1)
根据文件:
FlashMessenger帮助程序允许您传递用户在下次请求时可能需要查看的消息。
http://framework.zend.com/manual/current/en/modules/zend.view.helpers.flash-messenger.html
这会起作用吗?