F
Filament14mo ago
3rgo

Ability to skip validation on form ?

Hey everyone ! I'm working on a custom page that contains a form. I need to have 2 actions at the bottom : - a "save draft" action that performs the model update (even a partial one, ignoring empty fields), so ignoring the required rule - a "submit" action that performs a total data validation and save My save draft action is not on a submit button, but a regular one, with wire:click="saveDraft" , but I never reach the dd in that function, and validation fails on empty fields. Any idea how I can go around the required rule when using this method ? Thanks !
Solution:
validation is run when calling $form->getState().. You can get the rawstate without validation$form->getRawState()...
Jump to solution
6 Replies
awcodes
awcodes14mo ago
What’s the point of validation at all if it can be bypassed?
3rgo
3rgoOP14mo ago
My form is for a grant application. There are a lot of fields, so the applicant can partially fill the form, save a draft, then come back later to finish it
Solution
ZedoX
ZedoX14mo ago
validation is run when calling $form->getState().. You can get the rawstate without validation$form->getRawState()
ZedoX
ZedoX14mo ago
However this won't prevent browser side validation with some rules like required on a text input
josef
josef14mo ago
One possible solution would be to not set validation rules on the fields, and only apply custom ones when using submit
3rgo
3rgoOP14mo ago
Yeah that's what I did after all

Did you find this page helpful?