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