watch form values, sync problem #4358
-
Sync problem between form error and form state valid when using There is a form with a lot of inputs ( I am doing something wrong? Vue 3.3.4
Reproduction stepsbug VersionVue.js 3.x and vee-validate 4.x What browsers are you seeing the problem on?
Relevant log outputlog Demo linkwww Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Moved this to a discussion since it is not an issue. You could watch the values for sure but you could also make use of the const {
meta: myFormMeta,
values: myFormValues,
handleSubmit
} = useForm({
validationSchema: YUP_SCHEMA,
initialValues: FORM_DEFAULT,
validateOnMount: false,
keepValuesOnUnmount: false,
})
const submit = handleSubmit(async (values) => {
await uploadData()
}})
watch(
myFormValues,
async () => {
await submit();
},
{
deep: true,
immediate: false,
}
) The |
Beta Was this translation helpful? Give feedback.
Could be tricky to do that since you will rely on async code executing in order (vee-validate watcher, then yours).
But you can do it with
@vueuse/core
package withuntil()
.This is not guaranteed, but something like this code work.