You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I think I have multiple problems here, but first is it safe to use useField(...) with the same input name more than once and additionally an <Field :name />?
I use nested components and need different data of an input in various places (meta, value data for example).
On the hightest point I initilize the form with an simple useForm() and here I use a computed value to dynamically determine my input fields, which I render with a v-for and a unique key with a child component.
In this child component, I use the input type to decide which input element should be rendered (e.g. dropdown, text input, etc.) and mount another child component accordingly. There, in turn, I also used a generic component that is responsible for displaying a label and the validation errors. For this I use the <Field :name /> component of vee-validate and load the previously mentioned input type in a slot.
I know it sounds complicated and unfortunately I can't show you the complete code. That's why I have more the question, does it theoretically work that I use useField(name) and <Field :name /> several times, but with the same name?
In the devtools of vee-validate, I see the fields continue to count up whenever inputs are added or disappear, even though the fields actually displayed match the rendered ones. As a result, although all the fields displayed in the devtools are valid, I cannot complete my form because old (already removed) fields were not valid. At least I think so, because the fields are no longer listed in the devtools.
Is there a way in the onUnmounted() hook to manually unregister the fields?
Or can I somehow see which of these fields are not visible in my form (see screenshot), so that I could debug deeper?
In the screenshot, I have added and removed some fields several times. It should only show that my form continues to count up the fields even though they are not listed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I think I have multiple problems here, but first is it safe to use
useField(...)
with the same input name more than once and additionally an<Field :name />
?I use nested components and need different data of an input in various places (meta, value data for example).
On the hightest point I initilize the form with an simple
useForm()
and here I use acomputed
value to dynamically determine my input fields, which I render with av-for
and a uniquekey
with a child component.On the first child component (from the v-for loop) I initilize the input with a schema and default value:
In this child component, I use the input type to decide which input element should be rendered (e.g. dropdown, text input, etc.) and mount another child component accordingly. There, in turn, I also used a generic component that is responsible for displaying a label and the validation errors. For this I use the
<Field :name />
component of vee-validate and load the previously mentioned input type in a slot.I know it sounds complicated and unfortunately I can't show you the complete code. That's why I have more the question, does it theoretically work that I use
useField(name)
and<Field :name />
several times, but with the samename
?In the devtools of vee-validate, I see the fields continue to count up whenever inputs are added or disappear, even though the fields actually displayed match the rendered ones. As a result, although all the fields displayed in the devtools are valid, I cannot complete my form because old (already removed) fields were not valid. At least I think so, because the fields are no longer listed in the devtools.
Is there a way in the
onUnmounted()
hook to manually unregister the fields?Or can I somehow see which of these fields are not visible in my form (see screenshot), so that I could debug deeper?
In the screenshot, I have added and removed some fields several times. It should only show that my form continues to count up the fields even though they are not listed.
Beta Was this translation helpful? Give feedback.
All reactions