This project illustrates the Filament Repeater field with positional element management. When selecting the top 3 tournament winner countries, each chosen country automatically becomes unavailable in the remaining dropdown selections to prevent duplicates.
The whole logic of this live-updated form is in the Filament Resource file, in its form()
method.
Repeater::make()
with ->defaultItems(3)->addable(false)->deletable(false)
to have strictly 3 items.Tournament
model, from method country()
->live()->disableOptionWhen()
method and the $get
variable inside to define which options should be disabled->afterStateHydrated()
in repeater to transform the results into the format we actually need to save to the DB.The full code of that method: