gwenaelp / vfg-field-array

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

Custom element fix #10

Open electromuis opened 5 years ago

electromuis commented 5 years ago

I had an issue with this config

data () {
            return {
                valid: false,
                success: false,
                loading: true,
                message: "",
                model: {
                    tournamentManagers: []
                },
                schema: {
                    fields: [
                        {
                            type: "array",
                            model: "tournamentManagers",
                            items: {
                                type: "select",
                                values: []
                            }
                        }
                    ]
                },
                formOptions: {
                    validateAfterLoad: true,
                    validateAfterChanged: true,
                    validateAsync: true
                }
            }
        },

It told me it couldnt find the element "field-select", which comes from

getFieldType(fieldSchema) {
        return "field-" + fieldSchema.type;
      },

Thats becuase the components property in the array element is not there, fixed by by ovveriding that at import

import fieldArray from "vfg-field-array/src/components/field-array.vue";

import fieldComponents from "vue-form-generator/src/utils/fieldsLoader.js";
fieldArray.components = fieldComponents

Vue.component("fieldArray", fieldArray);

But of course it would be better if this could be fixed in the module itself

gwenaelp commented 5 years ago

Hello,

I'll have a look at it and see what I can do! Thank you for the feedback!