Draggable / formeo

Drag & Drop Form Builder
http://draggable.github.io/formeo/
MIT License
533 stars 196 forks source link

elements in config will be ignored #208

Closed xitara closed 5 years ago

xitara commented 5 years ago

First of all, Formeo now becomes a top WYSIWYG editor 👍

Here my acutal problem: I want to add a custom- element and tested severial examples but no additional element wil lbe displayed. heres my code:

` const formData = <?= $this->vars['formModel']->attributes['form']; ?>;

const editor = new FormeoEditor({
    editorContainer: '.build-form',
    i18n: {
        extension: '.lang',
        location: '<?= $relativePath . '/xitara/formgenerator/assets/formeo/lang/'; ?>',
        langs: ['de-DE', 'en-US'],
        locale: 'de-DE',
        override: {
            'de-DE': {
                multiple: 'Mehrfachupload',
            },
        },
    },
    elements: [
        {
            tag: 'input',
            attrs: {
                type: 'radio',
                required: false
            },
            config: {
                label: 'Radio Group',
                disabledAttrs: ['type']
            },
            meta: {
                group: 'common',
                icon: 'radio-group',
                id: 'radio'
            },
            options: [1, 2, 3].map(i => {
                return {
                    label: 'Radio ' + i,
                    value: 'radio-' + i,
                    selected: false
                };
            }),
        },
    ],
}, formData);`

all of this is working well, except the additional element. is this a bug or is it my fail?

Edit: i use the release 1.0.12

DivineLawnmower commented 5 years ago

@xitara Not sure if you worked it out but for anyone else:

Custom elements need to be added inside a "Controls" property as below:

` var formeo = new FormeoEditor({

    editorContainer: '#formeo-editor',
    svgSprite: 'https://draggable.github.io/formeo/assets/img/formeo-sprite.svg',
    dataType: 'json',
    debug: true,
    actions: {
        debug: true,
    },
    controls: {
        sortable: true,
        elements: [
            {
            tag: 'input',
            config: {
                label: 'Password',
                disabledAttrs: ['type']
            },
            meta: {
                group: 'existing',
                id: 'password',
                icon: '***',
            },
            attrs: {
                type: 'password'
            },
        },
        ],
    },

`

xitara commented 5 years ago

i'll try it, thx

xitara commented 5 years ago

late reply, but it works