Field value doesn't change #3226
-
BaseInput:
Parent:
The discount reactive property can have an initial value, which propagates just fine to the useField() in my VBaseInput, also if i change it, the new value updates in the child and also in the ParentForm reactive prop as you would expect.If i manually change it, as i do in the filter, the useField()'s value from the child completely ignores the modelValue prop's value. Kind of acceptance criteria: User type 12 in the input, the ParentForm reactive prop changes to 12 and it propagates to the VBaseInput through the :modelValue bind which also changes the inputValue that comes from useField(). Can anyone give me some assistance here, please? Update: example here |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
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 Your usage of 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 stuff, like it doesn't even use |
Beta Was this translation helpful? Give feedback.
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 themodelValue
yourself and update the model inside vee-validate, so something like this should work:I would have updated your example but it seems to be missing a lot of…