validate before requires confirmation

Hi, can we do validation before requires confirmation ?
3 Replies
DrByte
DrByte2y ago
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\TextInput $component) {
$livewire->validateOnly($component->getStatePath());
})
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\TextInput $component) {
$livewire->validateOnly($component->getStatePath());
})
See: https://laraveldaily.com/post/filament-validate-one-form-field-live-before-submit and https://filamentphp.com/docs/3.x/forms/advanced#field-updates
Ricardo Sawir
Ricardo SawirOP2y ago
It's a solution, but I was thinking to not use the live one.... simply just a button... when clicked it will need to requires confirmation... however, the current behaviour is it will show the requiresConfirmation, and then validate that.... which also doesnt dismiss the confirmation modal
Mark Chaney
Mark Chaney2mo ago
@Ricardo Sawir ever figure this out? Wanting this as well. Its a large form and not interested in using live either. As you mentioned, the confirmation model is staying up is weird and simply pretty two buttons before it even validates is just weird. found a solution
->requiresConfirmation()
->modal(function () {
try {
$this->form->getState();
return true;
} catch (\Exception $e) {
return false;
}
})
->requiresConfirmation()
->modal(function () {
try {
$this->form->getState();
return true;
} catch (\Exception $e) {
return false;
}
})

Did you find this page helpful?