openfext / vue-form-builder

Build powerful vue form with JSON schema and composition api.
https://openfext.github.io/vue-form-builder
MIT License
386 stars 45 forks source link

Problem when updating parent data #8

Closed codanux closed 5 years ago

codanux commented 5 years ago

I encountered with an issue while updating parent data here:

https://github.com/codetrial/element-form-builder/blob/22916aa8d4074998c21533b9c9b79a8305512e7d/src/formbuilder.js#L41

Here is a quick fix I applied

watch: {
    formValues: {
      handler: function handler(formValues) {
        this.updating = true;
        this.$emit('update:model', formValues); // model props update
      },
      deep: true
    },
}

I can send a PR if needed.

Regards

felixpy commented 5 years ago

Sorry for late response, maybe using v-model can solve this problem?

https://github.com/codetrial/element-form-builder/blob/17e44f1c1373fa01cb16d5f07bce68601d310184/examples/simple-demo/src/components/FormBuilderPreview.vue#L12

Refer to this feature of Vue.js:

https://vuejs.org/v2/guide/components.html#Using-v-model-on-Components