I
I
Ivan Kolesnik2016-06-02 00:49:46
Yii
Ivan Kolesnik, 2016-06-02 00:49:46

Does url change when action is returned in Yii2?

Guys, we need a helper. There is a task: two-stage registration with verification and use of Active Form. Not the essence of what and how it works, it works separately. The problem is this: when I verify the data from the first page and write

if ($model->load(Yii::$app->request->post())) {
            if ($model->validate()) { 
                     return $this->actionSecond($model);
            }
        }

which checks the form for validity and, in case of correct filling, redirects to the actionSecond controller and the URL should, theoretically, turn from the initial /index to /second ... The actionSecond() function itself does not return anything super special, it verifies in turn, its form, renders the view and passes the data
// ...

if ($model->load(Yii::$app->request->post())) {
            if ($model->validate()) { 
                return $this->actionFinish();
            }
        }

return $this->render('view', [
               'data' => $data,
           ])
// ...

Due to the fact that the route does not change (the same sad / index also hangs in the console), then verification occurs through the actionIndex handler, and since it is "not verified", then it stupidly redirects me back to /index and I stupidly get stuck in this cycle, having no way to get to the actionFinish-controller at all.
I appeal to your help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Soshnikov, 2016-06-02
@artem90

1. To change the route, it is necessary to return not actionSecond, etc. And
$this->redirect("/my/controller/second")
2. Either change the route and add a check to the stage in the form, in the form of a hidden field, etc. And check this value in index and distribute it to the necessary actions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question