-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
What happened?
With help of 3 basic composables from Vee-validate (useForm, useField, useFieldArray) I can create about any form one can think of.
But I stumbled upon a bug that occurs, when the useFieldArray is combined with useField only for boolean values.
Imagine following structure:
type User = {
name: string
roles: Role[]
enabled: boolean
}
type Role = {
text: string,
isDefault: boolean
}
When a form like this gets created, everything works fine exept the isDefault attribute. When the value of isDefault is false the attribute doesnt get to the submitted values at all, it just gets pruned. No matter if the false value got there from initialValues or it was set by user.
I dont see any reason why the attribute isDefault should get pruned based on the value. If it meets the conditions from validation and it got registered to the form via useField, it should be present in the final values.
Reproduction steps
- Submit the form provided in demo application and look to console for output.
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
- Chrome
- Firefox
- Safari
- Microsoft Edge
When I submit the form in demo link provided, this is the log I get.
As seen, the isDefault attribute is completely missing, unless it is true. Opposed to the enabled attribute which works completely fine.
Demo link
https://stackblitz.com/edit/vitejs-vite-r3tbk5jd?file=src%2FApp.vue
Code of Conduct
- I agree to follow this project's Code of Conduct