Use $get to find repeater value
Hello - I am using a repeater on a form. Within the repeater, I want the user to select an option from a list. If a new section is added to the repeater, I do not want the category that has already been selected above to be an option. I am trying to use $get to find the repeater but nothing seems to work. I've tried
$get('selections')
and $get('../selections')
but nothing has worked. What am I missing?
13 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I found this yesterday. I'm pretty sure I tried
getState
and got an error. But I'll try it again
When I try this:
I get an error saying Method App\Filament\Resources\OrderResource\RelationManagers\SelectionsRelationManager::getState does not exist.
Hello! Sorry for digging up the thread, did you find a way to make it work ? @bwurtz999
@sparkyyy_ yes I did. I wasn't going up enough levels
$get('../../selections')
solved it for meI'll try this tomorrow! Thanks for the quick response 🙂
Good morning 🙂
I tried to adapt your code to my problem but it seems like the condition is never fulfilled so I still have all the options.
Are you sure this is all the code you have?
0 is not necessarily a repeater index
usually they are uuids
Yes I noticed that, when I
var_dump
my repeater, I get a uuid but it changes every refresh
Any idea?Arr::first($repeater) ?
Ok, I almost made it work
Now when I pick an option, this option is not available for other instances but it also removes it from the input 😦
Here is the code :
you could use $state to get the current value
and make sure its present in this set of options
@sparkyyy_ I think you're missing something in the if statement. It wasn't in the original I posted in this thread, but here is what I use that now works:
I think because you don't have
&& $repeater['menu_category'] != $thisMenuCategory
is why it keeps being removedOh okay, I tried to do something with the state but couldn't make it work
I'll be on a vacation until Monday but I'll keep you updated. Thanks anyway! 🙂
Hello! I hope you are doing well 🙂
Thank you so much, this is exactly what I was looking for and it is working 🥲