Replies: 1 comment 2 replies
-
Hello and thank you for the kind words. You can submit what you need here to the submit function, let's say you want to pass the form values in the submit event: // vee-validate sends the values as the first argument to your handleSubmit success callback
// the values here are readonly
const onSubmit = handleSubmit((values) => {
emit('submit', values);
}, onInvalidSubmit);
// or grab them from `useForm`
const { handleSubmit, values } = useForm();
const onSubmit = handleSubmit(() => {
emit('submit', values);
}, onInvalidSubmit); This will effectively pass the form data to the parent component using the <MyForm @submit="onSuccess">
<!-- ... -->
</MyForm>
<script setup>
function onSuccess(values) {
values.name = '3'; // this won't change the form values, you only receive a deep copy version of it
}
</script> If you want to change some things in the form, then it could get more complicated here but it is still possible because you can also pass the form actions object to your parent which will allow it to change values, errors or reset the form if needed. This is covered here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @logaretm,
Today I saw your presentation about vee-validate, on the vue,js nation conference, and I have some questions about the enhanced UX form example that you presented, because I found it very interesting and I tried to replicate it. The main question that I have it's what's exactly that I need to pass to the emit when I reuse the component in order to trigger the validations? Because I think (I'm not sure, maybe I'm missing something) I also need to pass some props to register the current fields that need validation, i.e, one prop for schema and another to handle initValues if i need it. So now if I tried to submit the validation will trigger but I still don't know how I could manipulate the values once the form is valid.
I was trying with some custom components that i got defined via the useField so I don't tried yet with the components that come with vee-validate.
The example was this.
And thanks for your work! this library it has helped me a lot when need to handle validations in my foms.
Beta Was this translation helpful? Give feedback.
All reactions