Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Template Hooks

Phat Tran edited this page Sep 26, 2018 · 2 revisions

How to define hooks for Form Builder Template

Pass into the options property:

<form-builder type="template" v-model="formData" :options="formBuilderOptions"></form-builder>

With your option hooks like this:

data() {
    return {
        formBuilderOptions: {
            hooks: {
                'Section.beforeAdd': function(sectionInfo) {
                    // action here, you can use sectionInfo object...
                }
                ... // more hooks below...
            }
        }
    }
}

Available Hooks for Form Builder Template

Hook Name Passed Parameters Description
Section Hooks
Section.beforeAdd object sectionInfo Before a new section will be added (when you click Add Section button).
Return false to prevent adding.
Section.afterAdd object sectionInfo After a new section has just added.
Section.beforeRemove object sectionInfo Before section will be removed (when you click Remove Section).
Return false to prevent remove.
Section.afterRemove object sectionInfo After section has just removed
Row Hooks
Row.beforeAdd object rowInfo, object sectionInfo Before a new row will be added (when you click Add Row).
Return false to prevent adding.
Row.afterAdd object rowInfo, object sectionInfo After a new row has just added.
Row.beforeRemove object rowInfo, object sectionInfo Before row will be removed (when you click X).
Return false to prevent remove.
Row.afterRemove object rowInfo, object sectionInfo After row has just removed
Control Hooks
Control.beforeAdd object controlInfo, object rowInfo Before a new control will be added (when you has just dropped a control into a row).
Return false to prevent adding.
Control.afterAdd object controlInfo, object rowInfo After a new control has just added.
Control.beforeRemove object controlInfo Before control will be removed (when you drag control in a row and drop it into sidebar).
Return false to prevent remove.
Control.afterRemove object controlInfo After control has just removed
Sidebar Hooks
Sidebar.beforeOpenConfig object controlInfo Before open config sidebar (settings for control). Return false to stop opening.
Sidebar.afterOpenConfig object controlInfo After opened config sidebar (settings for control).
Sidebar.beforeApplyConfig object controlInfo Before apply new settings for control. Return false to apply.
Sidebar.afterApplyConfig object controlInfo After applied new settings for control.

Your needed hook doesn't available? Contact me. If it's worth to create, I would gladly create a new specific hook for you :D