Searchable Not Working When Preload is Set For Select Field With relationship
I have this code
when the preload is set the searchable will not work because of this code in filament select field
above code will block the code of
$this->getSearchResultsUsing
which defined in the relationship
method.
My question is why is that? In my use cases I want to preload the data at first with some limit and allow user to search for the rest of the data.27 Replies
Any suggestions?
if you set ->optionLimits(10) -> is the data exist?
just to make sure if the data loaded correctly
no need for optionLimits. it already take the default limit which is 50 when you are using
relationship
with searchable
. and yeah the data will load but the search will not works
since the hasDynamicSearchResults
will return false because the preload is set
which makes the search feature by database disabled. if you remove the preload then the search will works as expected but you will lose the ability to see option loaded when open the select field
i know why it doesnt work
try this
change the order
I try it but still the same problem.
oky, let set other option, cuz i dont think thats because of this method
ive done it before, my code look like this
and it works
did u changed the relationship right? not use classroom
Of course bro. Please read the functionality of
hasDynamicSearchResults
its says that if the field has relation (which means if relationship
is set) and the search column is set also (which means you specifiy the column in the relationship
) then check if preload is set return false otherwise return true. So the dynamic search will not work if its preloaded. (Dynamic search by database not a normal search in front end)so if you delete ->preload() and the ->searchable() it will show the options?
just want to make sure the relationship is works and the data is exist in the options, cuz sometimes i did sth wrong with the data or relationship, cuz its same code, i try ur code but with my own data, it works, the preload works and i can still search the data
What do you mean by
search
is it normal search or database search?
When you search does word "searching" appears?this is wht i mean i can still search the data even tho i use preload

so i search matthew, and it will show all the matthew data
is that wht u mean by search?
or did i missunderstnd u
Its a normal search bro. Try to search a data that is not displayed at first open of the select feild. Like if you display the firs 10 records try search for a records outside these 10
yeah it still works, i set the preload 5 and it shows 5 data, then i search for the record that not displayed in first 5 data that shows in the first


Can you please record a video when you search?. Just to see how the search is working.
im using ur same script but diffrent relationship
Yeah its a normal search bro. Fill your data with records more than 100 record
Then search for the last record
It will not get it
Or remove
preload
And search again
You will see different kind of search and each time you search it will take time to get the data
Which means (dynamic search is enabled)i've 50 data already, whts the diffrent with 100 data?
i have 50 classroom
The defaul option limit is 50
ok so ill try add one more
so it will51
Can you check this apporoch
Delete the preload
still works
And you will see different kind of search
I will show you the difference between the dynamic and normal search
i've also try this, i have 51 data and try to search the last one and it works
i know the diffrent if we dont use preload it will takes some time, but if we add the preload it will search not that long
well my point is, with the same code as u put it still works in my project, idk wht exacly made urs not work as mine, but yeah it works on me hahaha
Ok according to this issue
https://github.com/filamentphp/filament/issues/16423
Its solved in the latest versions
GitHub
Dynamic Search Not Working When preload is set for a relationship S...
Package filament/filament Package Version v3.3.18 Laravel Version v12.x Livewire Version v3.x PHP Version 8.2 Problem description I have this code Select::make('product_id') ->preload() ...