-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return to previous page after deletion #394
base: master
Are you sure you want to change the base?
Conversation
For example, after deleting from the page /index?page=2 will redirect to the page again
@gladunrv I agree with the idea but I'm not really found of the solution provided here. We may want to use I would:
What do you think? NB: This will use sessions instead of the HTTP referer.. |
@machour We tried similar things in https://github.com/schmunk42/yii2-giiant, especially with |
@@ -147,7 +147,12 @@ public function actionDelete(<?= $actionParams ?>) | |||
{ | |||
$this->findModel(<?= $actionParams ?>)->delete(); | |||
|
|||
return $this->redirect(['index']); | |||
list($actionID) = Yii::$app->createController(parse_url(Yii::$app->request->referrer, PHP_URL_PATH)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you're assuming that parse_url(Yii::$app->request->referrer, PHP_URL_PATH)
will return correct route?
This is looks brittle at best. Referrer is not always available, and assumption that URL path is a correct route and |
Passing previous URL in a GET variable sounds like slightly more reliable solution. @gladunrv would you like to adjust the pull request? |
How about using |
For example, after deleting from the page
/index?page=2
will redirect to this page again