F
Filament8mo 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
awcodes8mo ago
What’s the point of validation at all if it can be bypassed?
3rgo
3rgo8mo 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
ZedoX8mo ago
validation is run when calling $form->getState().. You can get the rawstate without validation$form->getRawState()
ZedoX
ZedoX8mo ago
However this won't prevent browser side validation with some rules like required on a text input
josef
josef8mo ago
One possible solution would be to not set validation rules on the fields, and only apply custom ones when using submit
3rgo
3rgo8mo ago
Yeah that's what I did after all