-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resetForm does not properly reset array with useFieldArray & useField #4519
Comments
This is because resetForm({ values: val }, { force: true }) Consider using |
Hi thanks for the reply. I was convinced I had tried force before as it is documented in the docs but it didn't seem to do anything, however I now found out that our package version didn't have this feature yet (4.9). As for the store, it was mostly for the reproducable. |
While it works, I would be careful with using But generally, I wouldn't use stores for forms anyway as I believe form state is ephemeral. However, I would consider form-centric apps an exception, an example that comes to mind is TypeForm. But it is definitely up to you and what works best for your team. |
What happened?
When using custom inputs (useField) in a repeatable form (useFieldArray) and altering the state with resetForm, the array does not properly reset causing empty objects to appear in the array.
The issue does not appear when not using useField and working with
v-model
with field.value.property from useFieldArray. However, this makes it unable to use meta etc. from useField.Related issue I've found: #3934
Before I opened this issue I had also opened this discussion:
#4516
Reproduction steps
Workaround:
Follow NOTE instruction in src/components/ItemFields.vue
(Replace custom input with normal input + v-model)
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
No response
Demo link
https://github.com/DrunkenToast/vee-validate-fieldarray-usefield
Code of Conduct
The text was updated successfully, but these errors were encountered: