sethsandaru / vue-form-builder

Super Form Builder built on top of Vue with Drag & Drop functionality, savable-form-schema and easy to maintain/upgrade your form.
http://vue-form-builder.sethphat.com
MIT License
414 stars 129 forks source link

Adding custom controls #65

Closed Sefux closed 4 years ago

Sefux commented 4 years ago

Hi @sethsandaru,

great project, thanks for creating it. I am using V2.0.1

I am having problems adding custom controls. I tried to follow your instructions from here. I can see my new control in the sidebar, but when i click to add i am getting this error:

Failed to mount component: template or render function not defined.

found in

Anonymous ControlView Draggable NormalSectionView SectionContainer FormBuilder ...

Do you have any advice on how to handle this? I can set up a test repository if you can not reproduce the error..

Thanks in advance

Sefux commented 4 years ago

never mind, i found a way to include the control/config.

in the registration options i switched from using "require" to an "import" statement. Now it work's.

Sefux commented 3 years ago

Hi @eliveltonrangell ,

not quit sure what is not working for you, but to be more specific...

in your main.js|ts file you include something like this:

Vue.use(VueFormBuilderPlugin, {
    controls: {
        'switch': {
            name: "Switch Field",
            description: "Single Switch",

            /**
             * Control View Mapping
             */
            fieldComponent: require('./custom-controls/switch/SwitchControl'),
...

The last line is where the require-statement should be changed to an import-statment:

import SwitchControl from './custom-controls/switch/SwitchControl'
Vue.use(VueFormBuilderPlugin, {
    controls: {
        'switch': {
            name: "Switch Field",
            description: "Single Switch",

            /**
             * Control View Mapping
             */
            fieldComponent: SwitchControl ,
...

You have to do the same for the configComponent.

hope it helps you... probalby you write here if that is the case, then documentation should be updated.