Select filter throwing error when using relationship
This is my code and this gives error https://flareapp.io/share/w5BnMJv5#context-app-views . This is working in all my other resources except for this one. If I use any other filed like id or phone or anything else it takes a lot to load and crashes my whole application. But if I do
this works. Am I suppose to do it like this ? Also, when I use relationship in other resources as well, it gives all data not the relationships one.
Flare
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string, null given, called in /Users/namrata/ug/backend/storage/framework/views/ccaf1eba786fda1c93f5e422c4e8cc96.php on line 86 - The error occurred at http://backend.test/admin/product-slugs
4 Replies
Check your users table, make sure you don't have any with a null 'name', which would cause that $label error.
Are you making the select searchable()? If not, and you have a lot of users, then trying to load them all into a select will be a problem.
Yes I have a lot of users and it is trying to get all the users but isn't relationship() suppose to give the available users in that table only ?
It’ll return whatever the relationship returns, modified by any query modification in the third argument. So unless the ‘users’ relationship itself constrains the query, your first example will return all users. The second will return all that have a productSlug relationship.
To automatically constrain the query, make it searchable(), and optionally add preload(), which (when searchable) loads the first 10 (I think) records.
Solution
Ok thank you