-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModelAdmin SearchForm filters only on the first field #9356
Comments
Same issue bugged me as well. I agree it feels unexpected and counter intuitive. |
Hey @lekoala, thanks for raising this! My initial impression is that this would require an expansion of the |
@Cheddam something like this would work for me
this way, you can opt in to filter on multiple fields by default by setting the "global" config to true |
Related: #9341 aims to implement proper APIs for determining which (single) field to use for the search bar. When tackling this issue, we'd likely now be looking at expanding that API. |
@Cheddam while this is being improved, any idea how to simply allow searching on multiple fields? It's really not clear how to do this properly |
@lekoala You might be able to sufficiently modify the behaviour of the default search field by customising |
@Cheddam i may be wrong, be as far as I can tell, gridfieldfilterheader applies its change AFTER getList is called no? calling something like
will show a sql statement without any where clause applied (even though I have a search parameter in the search bar) |
@lerni so since there is no easy solution, I had to build one. not sure it's the best way, but it works! the class is here the idea is to override the default search context in the GridFieldFilterHeader it's not so easy to do, because there is no way to set the searchContext, so I had to use reflection to do so. then, the idea is simply if there is only one search argument to do a filterAny for all availables filters. as an added bonus, i deal with multiple words as multiple AND/OR groups. sample usage in model admin
|
@Cheddam using my current solution feels much better than the default behaviour. having to click on the dropdown and do a specific search should really not be the default behaviour in my opinion. for members list (and probably lots of other types of data) it makes much more sense to search on firstname, surname and email. i think it's really sad that there is no built in option for this. |
For reference |
Just making a note here as it's listed in the description but not as a comment, there's an open pull request by @maxime-rainville to address this: #9836 |
Linked PRs have all been merged |
Affected Version
4.4.4
Description
So I have this model admin instance displaying members
If I type something in the search bar, it searches only on the first name. Data posted is something like
it's not searching on all searchable fields by default. which means you need to use the little dropdown to search each time by a specific field. It's very counterintuitive in a google era where people type stuff and expect the system to match records based on that.
Steps to Reproduce
Am I missing something ? Also, it's very confusing at the moment to know how to properly deal with this since we are in the middle of deprecated features (searchform getting replaced by the gridfieldfilterheader).
Any idea how to "simply" match on all searchable columns by default?
Acceptance criteria
Pull requests
The text was updated successfully, but these errors were encountered: