F
Filament2y ago
sqrt

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
Dan Harrin
Dan Harrin2y ago
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
sqrt
sqrtOP2y ago
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?
$tempOccupancy = array_diff($this->occupancyArray, [$state]);
return VentUnit::where('user_id', Auth::user()->id)->whereNotIn('id', $tempOccupancy)->pluck('name', 'id');
$tempOccupancy = array_diff($this->occupancyArray, [$state]);
return VentUnit::where('user_id', Auth::user()->id)->whereNotIn('id', $tempOccupancy)->pluck('name', 'id');
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.
Dan Harrin
Dan Harrin2y ago
wooo 🎉

Did you find this page helpful?