So far I managed this: ```php Forms\Components\Toggle::make('is_approved') ->reactive() ->af
So far I managed this:
Yes I can still save my form now.
Forms\Components\Toggle::make('is_approved')
->reactive()
->afterStateUpdated(function ($component, $state, EditSampleProduct $livewire) {
$livewire->resetErrorBag($component->getStatePath());
if ($state === false) {
return;
}
$items = $component->getContainer()->getParentComponent()->getOldState();
$approvedCount = collect($items)
->pluck('is_approved')
->filter()
->count();
if ($approvedCount > 0) {
$livewire->addError($component->getStatePath(), 'cannot approve more than 1.');
}
}),Forms\Components\Toggle::make('is_approved')
->reactive()
->afterStateUpdated(function ($component, $state, EditSampleProduct $livewire) {
$livewire->resetErrorBag($component->getStatePath());
if ($state === false) {
return;
}
$items = $component->getContainer()->getParentComponent()->getOldState();
$approvedCount = collect($items)
->pluck('is_approved')
->filter()
->count();
if ($approvedCount > 0) {
$livewire->addError($component->getStatePath(), 'cannot approve more than 1.');
}
}),Yes I can still save my form now.