-
Hi All, I am writing some custom validation components. I have a parent component with a slot that could contain input components that utilize useField. I would like this parent component to have access to fields inside the slot. Do I need to have a form element tag in my parent component for useForm to work properly? I am not using any of the submit functionality as my forms are not submitted but rather maintain a state in an application. If I want to use useForm inside my parent component what kind of information do I need to pass to the useForm hook function (if any??) to get access to child components that use useField? Anything specific I need to do when using useField to ensure accessibility by the useForm hook? thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
No, it is not required. And You can use either I suggest you try it first and see what doesn't work and I will be happy to help then. |
Beta Was this translation helpful? Give feedback.
-
Hi @logaretm, so if in my parent component I call useForm(): const { errors } = useForm(); Would you expect the errors computed to contain errors for all descendent fields/inputs that call useField? What is the scope for useForm? All descendents? What if a descendent also calls useForm()? Thanks! |
Beta Was this translation helpful? Give feedback.
No, it is not required. And
useForm
isn't required either if you plan to track your form values withv-model
manually.You can use either
useForm
or<Form />
component but never both. Using either defines a form context for your components that useuseField
or<Field />
.I suggest you try it first and see what doesn't work and I will be happy to help then.