Answer the question
In order to leave comments, you need to log in
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),
]);
}
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 questionAsk a Question
731 491 924 answers to any question