-
Apologies if this is a noob question, I’m a Vue newbie. I’ve spent a day working through the docs and wasn’t able to find a way to attack this with my higher-order components approach. If there is a better place to post, please let me know. Given a Is there Form metadata (in the example below) I can access outside of the template tags? i.e watch for the Form to become valid. I've tried some of the examples in #853, but I wasn't able to access the
For example: <template>
<Form :validation-schema="schema">
<label for="fullName">Your full name</label>
<Field id="fullName" name="fullName" type="text" v-model="fullName"/>
<ErrorMessage name="fullName" class="mt-2 text-sm text-red-600"/>
</Form>
</template>
<script>
import { ErrorMessage, Form, Field } from 'vee-validate'
import * as yup from 'yup'
export default {
name: 'MyComponent',
components: {
ErrorMessage, Form, Field
},
setup () {
const schema = yup.object({
fullName: yup.string().required().label('Full Name')
})
return {
schema
}
},
data () {
return {
fullName: null
}
},
methods: {
addPerson () {
// Makes call to API.
}
}
}
</script>
P.s. Thanks for your great work on this! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I converted this to a discussion since it is more of a question than an issue.
You should use the function setup () {
const schema = yup.object({
fullName: yup.string().required().label('Full Name')
})
const { meta } = useForm({ validationSchema: schema });
return {
meta,
schema
}
}, Then you are free to |
Beta Was this translation helpful? Give feedback.
I converted this to a discussion since it is more of a question than an issue.
You should use the
useForm
composition function instead of theForm
component for that purpose (you can still use<Field>
component). Check the docs here.Then you are free to
watch
themeta.valid
and trigger a submit manually.