Answer the question
In order to leave comments, you need to log in
Yii2 GridView, how to change search view and add custom feature?
I use GridView in the admin panel.
It looks like this:
When using search filters, the url looks like this:
And then a few questions arose:
1) Can these search inputs and selects be moved to another place? (Well, for example, in a separate block on a site with pop-up show-offs, etc.?)
2) How can I finish this business so that, for example, to find all the articles that have more than 20 comments?
3) For example, if we have a module with articles and a user module. And there is a need to make a link in the user profile All articles of the user That
is, the
filter should be by user_id. It turns out that you need to write something like this:
<a href="/admin/ModelSearch[user_id]=32">Все статьи пользователя</a>
Or is there a more elegant way?
Answer the question
In order to leave comments, you need to log in
1) you can modify the gridview in any way, by inheriting, and add your own js scripts
2) in short - not a problem (GridView + ModelSearch). You make a filter, add a variable to ModelSearch, process this variable in the search method.
3) do in any place religiously suitable for you (it is logical that it will be an article controller), an action with the $user_id argument and return a list of articles in it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question