V
V
Vladimir2017-02-25 04:53:36
Yii
Vladimir, 2017-02-25 04:53:36

How to remove unnecessary parameters when forming a link (path) in YII2?

Either the skis don’t go ...
The link is formed like this: it should be without In the controller, the render view is as follows:
/admin/line/view?id=1&d_city=1&a_city=2
&d_city=1&a_city=2

public function actionView($id, $d_city, $a_city)
    {
        return $this->render('view', [
            'model' => $this->findModel($id, $d_city, $a_city),
        ]);
    }

Even if I leave only one $id, the link still remains the same.
All these three fields of the table with the INDEX key, if you remove the keys from d_city and a_city, then the path is formed without them
Tell me which way to look?
PS The links themselves are formed to the correct address and the pages are rendered without errors, you just need to remove these additional parameters.
Thank you in advance for your advice!
UPD:
findModel Code
protected function findModel($id, $d_city, $a_city)
    {
        if (($model = Line::findOne(['id' => $id, 'd_city' => $d_city, 'a_city' => $a_city])) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question