Open tbl0605 opened 1 year ago
I don't think this is intended, but not sure if it is a bug either, I never thought about this case nor it is in any of the tests we have.
Checkboxes are pretty unique, the reason it doesn't reset them is when you change the field name it finds that the possible values are still the same as the ones bound to the current fields so it doesn't remove them from the array but that could be just a mistake. I need to dig deeper into this, thanks for reporting it and I will have an update soon.
What happened?
Hi @logaretm, I don't know if I should open a bug report or a discussion, I find strange how vee-validate acts about "Paths creation and destruction" in some cases.
I have a page where a form is dynamically populated with fields, based on field descriptions extracted from JSON data. This JSON data can also dynamically change while page is open, and of course, the changes are reflected by creating/updating/deleting affected fields. I have some code that looks something like:
So far, so good, the most important part was that I didn't want to loose form values between JSON data changes (even when fields were gone), so I successfully used
:keep-value="true"
.But at the beginning of my developments I didn't add
:keep-value="true"
because I first didn't know about the "Paths creation and destruction" caveats. And of course, when value ofdesc.index
changed, underlying modelmodels[desc.modelName]
was reset toundefined
.And this is where I observed a strange thing: underlying model is not reset to
undefined
when multiple checkboxes are bound to same name.I made a demo to show the case: https://codesandbox.io/s/vee-validate-test-jd24vr
Click the "Generate new :key value" button and you will see all fields reset to
undefined
except for the "A", "B" and "C" checkboxes.So my question is: is this expected behavior for multiple checkboxes? Or is it just a caveat? Or a bug?
Thierry.
Reproduction steps
1. 2. 3. ...
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://codesandbox.io/s/vee-validate-test-jd24vr
Code of Conduct