gwenaelp / vfg-field-array

A vue-form-generator field to handle arrays
MIT License
39 stars 24 forks source link

Default object passed as references to all the components #1

Closed mix359 closed 6 years ago

mix359 commented 6 years ago

Hi, I'm trying this component for one of my project. I've followed one of the example that use this component in conjunction with the field-object, and following that example, in my schema I've an "items.default: {}".

Doing that, I've found a strange behavior: When I have more than once instance of the object, they are all referring to the same default object, so the similar fields are compiled with the same values in all the instances of the component. For example, if you have a text input in the schema of the field-object, all those text input will share the same values.

Looking at the code of the field-array.vue, I see that you're assigning the same object and pushing it to the value array (around line 89), shouldn't be deep cloned? So that every time there's a new instance of the object and not a reference to the same.

Thanks for your work! Daniele

gwenaelp commented 6 years ago

Solved by the PR #3 thanks to your amazing work! =D