Customize attach search query
Hi, I'm attempting to override the search query on an Attach Action, but can't seem to find if and how I can do that.
The idea here is that I'd like the search to apply the following SQL:
WHERE ´column´ LIKE 'search%'
Seeing as I don't want the attach dropdown to show items that don't start with the search query.
Is this possible somehow? Thanks!11 Replies
I already use that method for something else, but can I override the search logic itself in that method? Can I access the $search query in the method? Thanks for the help!
Depends where 'search' query is in your mind.
As in what I fill into the select, sorry if I don't make sense 🙈
See screenshot:
The search only applies to the numbers in front of the text (I set it like that using "recordSelectSearchColumns").
But I'd like, when I search for '1.1' it would only show me results that start with '1.1' and not results like for example '12.1.1'
Look at:
https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results
Likely need to pass $search into the closure.
Hmmm, my PHPStorm tells me this method is unknown on the Attach Action 🤔
It would be great if it'd be possible that way ofcourse!
I said to try passing search into the closure, not call a new function,
Might not work, I haven't checked but worth a try.
Solution
Else build your own attach action.
Oh apologies. I tried that and sadly it could not resolve $search
Alright, I'll take a look into building my own attach action, thanks for the assistance 👍