F
Filament9mo ago
Daniel

Avoid form submission on error

I managed having unique field values like described in this post: https://discord.com/channels/883083792112300104/1134208647052935198/1134211305763516517 But the form is still submitted. Is there a way to avoid form submission when there was an error in one of the Repeater fields?
3 Replies
toeknee
toeknee9mo ago
unique shouldn't be submitted if it fails validation. You need to trigger a failure too, not just an error message
Daniel
Daniel9mo ago
yeah, but how can i trigger the failure from within afterStateUpdated method?
LeandroFerreira
LeandroFerreira9mo ago
->afterStateUpdated(function($component){
throw_if($yourCondition, ValidationException::withMessages([
$component->getStatePath() => 'Your error message...',
]));
})
->afterStateUpdated(function($component){
throw_if($yourCondition, ValidationException::withMessages([
$component->getStatePath() => 'Your error message...',
]));
})
Want results from more Discord servers?
Add your server
More Posts