Remove options selected on a repeater form
i need remove the selected modules from the select, that is inside of a repeater
the code is actually that doesnot works is:
$modules = Module::query()->pluck('name', 'id')->toArray();
return $form
->schema([
Forms\Components\Repeater::make('Modules')
->schema([
Forms\Components\Select::make('modules')
->live()
->required()
->distinct()
->default('')
->options(function (callable $get) use ($modules) {
$repeater = collect($get('../../Modules'))->pluck('modules')->toArray() ?: [];
$idsToSkip = [];
if ($repeater !== null) {
foreach ($repeater as $module){
if (isset($module['modules'])){
$idsToSkip[] = $module['modules'];
}
}
}
$array = Module::query()->whereNotIn('id', $idsToSkip)->pluck('name', 'id')->toArray();
return $array;
}),
Forms\Components\TextInput::make('discount')
->label('Discount in %')
->live()
->numeric()
->minValue(0)
->maxValue(100)
->required()
->default(0)
])->columns(2)
selected'),
2 Replies
dont use disableOptionsWhenSelectedInSiblingRepeaterItems because this put the selected option on gray, i wanted that the element dissapear directly
GitHub
Remove options selected on a repeater form · filamentphp filament ·...
Package Form builder Package Version v3.0.0 How can we help you? i need remove the selected modules from the select, that is inside of a repeater the code is actually that doesnot works is: $module...