Custom input in Field component #3728
Unanswered
the-nightling
asked this question in
Q&A
Replies: 1 comment
-
Hello. So if you inspect the contents of
Note that it doesn't have any listeners for So for this case you may need to handle it manually by pulling in <Field
name="password"
v-model="user.password"
v-slot="{ errorMessage, handleChange }"
rules="required"
>
<div>
<CustomInput :id="'password2'" @update:modelValue="handleChange" />
<span>{{ errorMessage }}</span>
</div>
</Field> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, thanks for the awesome library.
I have a custom input component that can be used with or without validation. As such I'd like to exclude any validation logic in that custom component and keep all validation logic in the parent component that contains Form.
I've created a minimal example here:
https://codesandbox.io/s/veevalidatecustominput-0l5mos?file=/src/components/CustomInput.vue
However, I'm unable to use the following:
I've tried having the CustomInput emit the internal input's change, input & blur events and call handleChange & handleBlur from the slot prop but that didn't work. The input stays blank while displaying the validation message.
Is it possible to have a custom input in the Field component? If so can you give me any pointers.
P.S. I've seen the examples with useField but I'm trying to avoid having useField in the CustomInput component.
Beta Was this translation helpful? Give feedback.
All reactions