Modify the state of a select box in repeater when an item is added

When i add items to my repeater my select box should have option that is previously selected,i used this but i can see the other options too
->addAction(fn ($action) => $action->after(function (Forms\Components\Repeater $component) {
$component->state(function ($state) {
$answers = collect($state);
$type=$answers->pluck('select_product')->first();
$newAnswerKey = $answers->keys()->last();
$answers[$newAnswerKey] = ['select_product' => $type,];
return $answers->toArray();
})
}))
->addAction(fn ($action) => $action->after(function (Forms\Components\Repeater $component) {
$component->state(function ($state) {
$answers = collect($state);
$type=$answers->pluck('select_product')->first();
$newAnswerKey = $answers->keys()->last();
$answers[$newAnswerKey] = ['select_product' => $type,];
return $answers->toArray();
})
}))
How can change the options here..please help
1 Reply
SinthuMS
SinthuMSOP13mo ago
I set this to the select boxes
->disabled(fn ($state): bool => filled($state))
->dehydrated(fn () => true)
->disabled(fn ($state): bool => filled($state))
->dehydrated(fn () => true)
so it becomes disabled after being selected once.

Did you find this page helpful?