Is there a way to pass a query builder into searchable select to populate options?

I'm new to filament, it seems like there would be a way to pass in a custom query builder into a select component instead of being dependent on a relationship set up on a model. Is there a way to do this instead of having to fetch all of the options in advance?
Solution:
->searchable() ->getSearchResultsUsing( callback )...
Jump to solution
5 Replies
Tieme
Tieme10mo ago
You mean : https://filamentphp.com/docs/3.x/forms/fields/select#searching-options and : https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results
->options(User::all()->pluck('name', 'id'))
->options(User::all()->pluck('name', 'id'))
deadbeef
deadbeefOP10mo ago
That works for small data sets, but what if you don't want to return all of the available data to the browser? Instead, I'm looking to have the user to filter the select down by a search driven via an eloquent query.
Solution
Patrick
Patrick10mo ago
->searchable() ->getSearchResultsUsing( callback )
Tieme
Tieme10mo ago
and you can try passing parameters from other fields with $get to build your select https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-state-of-another-field
deadbeef
deadbeefOP10mo ago
Thank you!
Want results from more Discord servers?
Add your server