Saving form as draft and validate all except `required`
I have a couple of long forms that I'd like to save as a draft after a field is blurred. Most fields have some specific validation, and due to technical constraints, that validation is crucial (there's no other validation before putting in DB) . Most of the fields are marked as
->required()
.
How can I achieve this?
1. What's the best way to update the draft on every change in any of fields?
2. How can I apply all validation rules except ->required()
when updating draft? (The effect here would be that we're also giving instant feedback is field is not valid)
Note, that I'm using the form in a custom Page inside the panel.3 Replies
I built a custom save button for same and resume later which skips the get state, but also have a status so when they have published state certain fiels are reuqired. So the closures on the required would be like:
->required(fn(Closure $get) => $get('status') === 'published')
Thank you @toeknee that's good idea to play leverage closure for
->required(
call. I'll explore it.
Any idea on calling the method every time field value is entered?You would need to use the afterStateUpdated method