cakephp中的多重重定向
我想重定向到两个页面,一个是视图部分,另一个是索引部分 示例:我将添加新用户。在我点击提交按钮之后。 该页在新选项卡中有直接到索引页,并且还有一个重定向是视图部分。目前它只重定向到索引函数。我想在两个单独的或弹出窗口中重新定义索引和视图函数 控制器:cakephp中的多重重定向,php,cakephp,redirect,cakephp-2.0,cakephp-2.3,Php,Cakephp,Redirect,Cakephp 2.0,Cakephp 2.3,我想重定向到两个页面,一个是视图部分,另一个是索引部分 示例:我将添加新用户。在我点击提交按钮之后。 该页在新选项卡中有直接到索引页,并且还有一个重定向是视图部分。目前它只重定向到索引函数。我想在两个单独的或弹出窗口中重新定义索引和视图函数 控制器: public function add() { if ($this->request->is('post')) { $this->User->create();
public function add() {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
}
视图:
无法保存该用户。请再试一次。
添加用户
用户名
密码
角色
角色1
请输入有效的角色1111
试试这个:
控制器:
public function add() {
if ($this->request->is('post')) {
$flag='0';
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$flag='1';
$this->set(compact('flag'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
}
if($flag == 1){
//Use Jquery window.open()/
}
查看:
public function add() {
if ($this->request->is('post')) {
$flag='0';
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$flag='1';
$this->set(compact('flag'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
}
if($flag == 1){
//Use Jquery window.open()/
}
window.open ref链接是: