Skip to content

Latest commit

 

History

History
42 lines (36 loc) · 1.03 KB

02_conditionalLogic.md

File metadata and controls

42 lines (36 loc) · 1.03 KB

Conditional Logic Component

This component will enable the conditional logic functionality.

Enable Extension

import {ConditionalLogic} from 'js-pimcore-formbuilder';
document.addEventListener('DOMContentLoaded', () => {
    document.querySelectorAll('.formbuilder.ajax-form').forEach((form) => {
        new ConditionalLogic(form);
    });
});

Extended Usage

document.addEventListener('DOMContentLoaded', () => {
    document.querySelectorAll('.formbuilder.ajax-form').forEach((form) => {
        new ConditionalLogic(form, {
            conditions: {},
            actions: {
                toggleElement: {
                    onEnable: function (action, actionId, ev, el) {
                        console.log(action, ev, el);
                    }
                }
            },
            elementTransformer: {
                hide: function (el) {
                    el.classList.add('hidden');
                }
            },
            hideElementClass: 'fb-cl-hide-element'
        });
    });
});