Answer the question
In order to leave comments, you need to log in
How to "kosherly" cast the correct URL in Yii2?
What we have:
News model, controller and search model generated via CRUD. The model has a property containing the news category ID.
Further in the view in the list of news, next to the title of each news, there is an "icon" with the name of the category of this news (well, you know how it happens).
It is logical to hang a link to this icon to filter news for a given category. Of course, you can create a separate actionCategoryId that will search for this ID, but it's better to do this through the standard actionIndex. I do like this:
Html::a('Спорт', ['/news/index', (new NewsSearch)->formName().'[category_id]' => $model->category->id]);
(new NewsSearch)->formName().'[category_id]'
Answer the question
In order to leave comments, you need to log in
This method may help, but not much, in generating the name.
www.yiiframework.com/doc-2.0/yii-helpers-basehtml....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question