In some of my models I want the user, after doing a create or update actions, to be redirected to the previous page he was in (whatever page it as)
For now , each action has a preset redirect like this one:
public function actionCreate()
// Uncomment the following line if AJAX validation is needed
Now I’v been looking in the forum and found this code:
Normally urlReferrer will point to the previous page, but once you refresh current page, or submit current page, then urlReferrer will point to current page. If you want to go back to the previous page after you submit current page, then it’s better use session to store that page as returnUrl, so you can call redirect to back to previous page.
Add below session call before render().
public function actionIndex()
Then add code in your next page.
//if status updated, redirect to previous page
please I have the same prob, but I don't exactly understand how to use Johnny Gan's solution.
Could you please explain me (sorry for the noob question <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' /> )
to be clear I don't understan the second part of the solution (Then add code in your next page.) where should I add this code ?
Example: in my form , after I created a user I want to be redirected to his profile in view , so I put the first part of the code into actionCreate , and the second one into actionView.
(In my case the actions are from different models thus each part sits in different controller)