E
E
Elizabeth2017-06-24 22:45:12
Yii
Elizabeth, 2017-06-24 22:45:12

YII2. How to form a transition to a page depending on which page the user is on?

I have a simple post in this form, when you can add a picture, change tags and categories:
38aa1de9facf433ab483f994597af50f.png
This can also be done by clicking on UPDATE:
f06c62bf0ca549fe919a9c1c7e75b6cd.png
When you click on save tags, for example, there is a redirect to the main view page (view):
16bbffdea81c41b2baf0646e5a239bfe.png
But I would like to implement : if the user was on the view page before he moved to adding an image/tag/category, then return him there. if on the update page, then there. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-06-24
@elizaveta_kotik

Good evening.
Try like this:

return $this->redirect(Yii::$app->request->referrer);

B
Boris Korobkov, 2017-06-24
@BorisKorobkov

Option 1. In actionView/actionUpdate, save "view"/"update" + id to the session. When redirecting, take from the session.
Option 2. Add a new backAction + backId parameter to the "add"/"install" links and their form.action. When redirecting, take from get.
Option 3. The most cardinal is SPA (single page application). Change everything to ajax. There will be no redirects and page transitions at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question