Skip to content

Field value doesn't change #3226

Answered by logaretm
lebadapetru asked this question in Q&A
Mar 20, 2021 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Not sure if I'm following correctly, so to recap you want the input value to have two-way binding, meaning the parent can change the value and the child input should be able to pick up the new value with modelValue prop.

Your usage of handleChange is correct, but you need to watch the modelValue yourself and update the model inside vee-validate, so something like this should work:

const {
  value: inputValue,
   // ....
 } = useField(props.name, props.rules, {
   initialValue: props.modelValue,
});

// sync the model value with vee-validate's value
watch(() => props.modelValue, value => {
  inputValue.value = value;
});

I would have updated your example but it seems to be missing a lot of…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@lebadapetru
Comment options

Comment options

You must be logged in to vote
2 replies
@lebadapetru
Comment options

@imShara
Comment options

Answer selected by logaretm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants