Select once within Repeater
Hi, I have several devices assigned to the user. I also have a user's group and I try to assign some of user's devices to the group. For that I use Repeater. What I'm trying to do is allow for selection of certain device only once. In pure Livewire that would be possible using the except method limiting the remaining options from the list. In Filament I naively created the array of „taken” devices, but it is limit the choice for all Selects within the Repeater. Is there a way for the Repeater's record to know its „row”?
3 Replies
you would need to pass a function to options() which uses $get(‘../../repeatername’) to check which values are already selected and dont include them in the list
Right, I assumed I can only pass array to options. Sources always should be read. Thanks again
So, the
$get(‘../../repeatername’)
gives me the complete list (array) per each iteration over "row". And I think the row should know its "current" id (the key) so I can construct proper query for others. Or am I missing something?
this seems to do the trick
New issue – in order to add the relations I do return Group::class;
in getFormModel
to be able to get the hydration data. But in that case the Repeater wont fill. Using return $this->group
passed only the existing relations do the submit(). Is there a way to fill the repeater? I do not want to split add/edit functionalities.
ok, I did not ask. It seemed to simple to work, but it does in fact. This system is briliant.wooo 🎉