gwenaelp / vfg-field-array

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

Install both vfg-field-array and vfg-field-object #6

Closed kahunacoder closed 5 years ago

kahunacoder commented 5 years ago

In the following example: With container component and object as array item

You are using vfg-field-array and vfg-field-object. How do you install both? The docs say to do this in the main.js file

import ModuleLibrary from 'vfg-field-array' Vue.use(ModuleLibrary);

and import ModuleLibrary from 'vfg-field-object'; Vue.use(ModuleLibrary);

How do you use both?

gwenaelp commented 5 years ago

You need to implement your schema this way (this is just an example) :

{
    fields: [{
      type: 'array',
      label: 'Columns',
      model: 'columns',
      itemContainerComponent: 'AComponent', //optional
      showRemoveButton: false, //optional
      fieldClasses: 'arrayEditor', //optional
      newElementButtonLabelClasses: 'button is-primary', //optional
      items: {
        type: 'object',
        default: {},
        schema: {
          fields: [{
            type: 'input',
            label: 'Label',
            model: 'label',
          }, {
            type: 'input',
            label: 'Field',
            model: 'field',
          }],
        },
      },
    }],
  }

Does this answers your question?

kahunacoder commented 5 years ago

No, my problem is with installing both modules into my main.js file.

kahunacoder commented 5 years ago

import ModuleLibrary from 'vfg-field-array' Vue.use(ModuleLibrary);

and import ModuleLibrary from 'vfg-field-object'; Vue.use(ModuleLibrary)

Both modules are called ModuleLibrary

gwenaelp commented 5 years ago

Ah ok.

I think I need to change those README.

Actually you can name "ModuleLibrary" whatever you want:

import VfgFieldArray from 'vfg-field-array'
Vue.use(VfgFieldArray);

and

import VfgFieldObject from 'vfg-field-object';
Vue.use(VfgFieldObject)

This "ModuleLibrary" name is just a variable you instanciate with the import. Is it more clear? Tell me, to know if I can close the issue.

kahunacoder commented 5 years ago

Thank you that is what I needed to understand.