Morph col filter
how does one go about filtering a morph col? I can assign a user or a team to a task.. want a searchable select filter for it but I cant figure out how to do it
I was thinking of making 2 seperate ones (first select if you want to filter a User or Team, (assigned_type)
when filled in (assigned_id) appears with Users or Teams
its how I do create/update, but you cannot depend/have reactive filter inputs it seems)
Is there an easier way to achieve what I want?
14 Replies
but you cannot depend/have reactive filter inputs it seems)Did you try it? Not sure whether it works, but don't know why it shouldn't be possible with a filter form?
I was thinking of making 2 seperate ones (first select if you want to filter a User or Team, (assigned_type)Sounds good to me.
I dont know how to retrieve the value from the first filter in the second one..
$get
does not work as it does with form inputs
Solution
Don't use a
SelectFilter
, but a Custom filter with a formso one filter with the two fields?
Yep
It's one Filter anyway, right?
yes just making sure I understood right haha.. I shall take a look, cheers :)
got it working, thanks Dennis
seems there is also a built in way.. you shouldve known this. @Dennis Koch π https://filamentphp.com/docs/3.x/forms/fields/select#handling-morphto-relationships
(in case of future readers)
Actually I wanted to share this, then read that you want a Filter and then didn't forgot to mention it with the
->form()
solution π
all good haha, got pointed to it during code review :)
Just point it to the junior devs
I am the junior dev π
I meant me π
ahh lol
';/
\