php – yii2更新后返回上一页
作者:互联网
更新记录后,如何将用户重定向到上一页?这是典型的情况:
>用户位于索引页面中,并对记录中的结果或分页进行过滤,然后找到要编辑的页面,然后单击编辑按钮.他们更新该记录的数据,一旦他们点击“更新”按钮,他们就会被重定向到索引视图,但先前选择了过滤器/页面.
我已经尝试在更新后在我的控制器中使用下面
return $this->redirect('index',302); (this is not what I need)
return $this->redirect(Yii::$app->request->referrer); (this gets user back to update view and not to index view with filters)
return $this->goBack(); (this gets user to homepage)
谢谢!
解决方法:
在您希望用户重定向到添加的操作中
\yii\helpers\Url::remember();
现在接下来调用任何控制器,如:
return $this->goBack();
将用户重定向到“标记”操作.
标签:php,yii2,yii2-advanced-app 来源: https://codeday.me/bug/20190727/1553522.html