Seh*_*ong 1 php zend-framework
在完成重定向后,我怎么能发送额外的视图参数(例如$ this - > _ redirect-> gotoSimple();)?
例如,假设我有一个Edit操作,它将用户重定向到Error操作处理程序,我希望能够向其视图发送自定义的详细错误消息.为了更清楚地说明,流程将是:
一个快速的代码片段可能看起来像:
public function editAction() {
//DO THINGS...
// Upon failure
if($fail) {
$this->_redirector->gotoUrl('/error/index');
//TODO: I need to be able to do something like
// $errorView->errorMessage = "Generic error";
}
}
Run Code Online (Sandbox Code Playgroud)
我们非常感谢任何解决方案,甚至其他更好的方法.
不要gotoURL()用于内部重定向.使用gotoSimple().我最多需要4个参数:
gotoSimple($action,
$controller = null,
$module = null,
array $params = array())
Run Code Online (Sandbox Code Playgroud)
在你的情况下,它将是:
$this->_redirector->gotoSimple('index',
'error',
null,
array('errorMessage'=>$errMsg));
Run Code Online (Sandbox Code Playgroud)
详情Redirector Zend_Controller_Action_Helper请见.
| 归档时间: |
|
| 查看次数: |
6675 次 |
| 最近记录: |