Form Editor

Release 2.15.0 and above.

A form element editor plugin that can insert form elements and edit their properties.

Form editor example

How to Use

Loading Plugin Files

<!-- The SynapEditor object must exist for this to take effect,
     so include after the editor script files. -->
<script src="url of formEditor.min.js"></script>
<link rel="stylesheet" href="url of formEditor.min.css">

Adding Buttons to the Toolbar

You can add form element insert, properties dialog, and edit buttons to the toolbar area or the menu area.

Add to Toolbar

// synapeditor.config.js
//...
'editor.toolbar': [
    // Form element insert buttons
    'formEditor_text', 'formEditor_textarea', 'formEditor_select',
    'formEditor_radio', 'formEditor_checkbox', 'formEditor_button',
    'formEditor_hidden', 'formEditor_datalist', 'formEditor_fieldset', 'formEditor_form'
    //...
],
// ...

Form editor toolbar buttons

Form Element Insert Button List

KEYICONDescription
formEditor_texttextInserts a text field. (<input type="text">)
formEditor_textareatextareaInserts a text area. (<textarea>)
formEditor_selectselectInserts a select box. (<select>)
formEditor_radioradioInserts a radio button. (<input type="radio">)
formEditor_checkboxcheckboxInserts a checkbox. (<input type="checkbox">)
formEditor_buttonbuttonInserts a button. (<button>)
formEditor_hiddenhiddenInserts a hidden field. (<input type="hidden">)
formEditor_datalistdatalistInserts a data list. (<datalist>)
formEditor_fieldsetfieldsetInserts a fieldset. (<fieldset>)
formEditor_formformInserts a form. (<form>)

Properties Button List

KEYICONDescription
formEditor_textPropertiespropertiesOpens the dialog to set text field properties.
formEditor_textareaPropertiespropertiesOpens the dialog to set text area properties.
formEditor_selectPropertiespropertiesOpens the dialog to set select box properties.
formEditor_radioPropertiespropertiesOpens the dialog to set radio button properties.
formEditor_checkboxPropertiespropertiesOpens the dialog to set checkbox properties.
formEditor_buttonPropertiespropertiesOpens the dialog to set button properties.
formEditor_hiddenPropertiespropertiesOpens the dialog to set hidden field properties.
formEditor_datalistPropertiespropertiesOpens the dialog to set data list properties.
formEditor_datalistInputPropertiespropertiesOpens the dialog to set data list field properties.
formEditor_labelPropertiespropertiesOpens the dialog to set label properties.
formEditor_fieldsetPropertiespropertiesOpens the dialog to set fieldset properties.
formEditor_formPropertiespropertiesOpens the dialog to set form properties.

Form Element Edit Button List

KEYICONDescription
formEditor_boldboldApplies 'Bold' to the selected form element.
formEditor_italicitalicApplies 'Italic' to the selected form element.
formEditor_underlineunderlineApplies 'Underline' to the selected form element.
formEditor_strikestrikeApplies 'Strikethrough' to the selected form element.
formEditor_fillfillApplies 'Fill color' to the selected form element.
formEditor_borderColorborderColorApplies 'Border color' to the selected form element.
formEditor_lineThicknesslineThicknessApplies 'Line thickness' to the selected form element.
formEditor_lineStylelineStyleApplies 'Line style' to the selected form element.
formEditor_fontFamilyfontFamilyApplies 'Font' to the selected form element.
formEditor_fontSizefontSizeApplies 'Font size' to the selected form element.
formEditor_fontColorfontColorApplies 'Font color' to the selected form element.
formEditor_alignalignApplies 'Alignment' to the selected form element.
formEditor_deletedeleteDeletes the selected form element.

Configure the Plugin

Form Element Balloon Setting

You can directly configure the list of buttons that will appear in the form element balloon.

<table> <thead> <tr><th>Before setting (default)</th><th>After setting</th></tr> </thead> <tbody> <tr> <td>

Balloon default

</td> <td>

Balloon configured

</td> </tr> </tbody> </table>
// synapeditor.config.js
//...
'formEditor.config': {
    'balloon': {
        // balloon name : [array of button names to display]
        'formEditor_text': ['formEditor_textProperties', 'formEditor_delete'],
        'formEditor_textarea': ['formEditor_textareaProperties', 'formEditor_delete'],
        'formEditor_select': ['formEditor_selectProperties', 'formEditor_delete'],
        'formEditor_radio': ['formEditor_radioProperties', 'formEditor_delete'],
        'formEditor_checkbox': ['formEditor_checkboxProperties', 'formEditor_delete'],
        'formEditor_button': ['formEditor_buttonProperties', 'formEditor_delete'],
        'formEditor_hidden': ['formEditor_hiddenProperties', 'formEditor_delete'],
        'formEditor_datalist': ['formEditor_datalistProperties', 'formEditor_delete'],
        'formEditor_datalistInput': ['formEditor_datalistInputProperties', 'formEditor_delete'],
        'formEditor_label': ['formEditor_labelProperties', 'formEditor_delete'],
        'formEditor_fieldset': ['formEditor_fieldsetProperties', 'formEditor_delete'],
        'formEditor_form': ['formEditor_formProperties', 'formEditor_delete']
    }
}
//...
BALLOON NAMEDescription
formEditor_textBalloon that appears on the text field.
formEditor_textareaBalloon that appears on the text area.
formEditor_selectBalloon that appears on the select box.
formEditor_radioBalloon that appears on the radio button.
formEditor_checkboxBalloon that appears on the checkbox.
formEditor_buttonBalloon that appears on the button.
formEditor_hiddenBalloon that appears on the hidden field.
formEditor_datalistBalloon that appears on the data list.
formEditor_datalistInputBalloon that appears on the data list field.
formEditor_labelBalloon that appears on the label.
formEditor_fieldsetBalloon that appears on the fieldset.
formEditor_formBalloon that appears on the form.

Using the Form Element Event Setting Feature

You can set events using the form element's properties dialog.

(Dialogs where events can be set: text field properties, text area properties, button properties, select box properties, radio button properties, checkbox properties, data list field properties)

Event setting dialog

To use this feature, event attribute insertion must be allowed in the editor's content filter settings.

You can allow event attribute insertion by setting 'editor.contentFilter.allowEventAttribute' to true. (See: Content Filter)

Caution!

Security issues that occur due to using this option cannot be the responsibility of the provider.

<table> <thead> <tr><th><code>editor.contentFilter.allowEventAttribute: false</code></th><th><code>editor.contentFilter.allowEventAttribute: true</code></th></tr> </thead> <tbody> <tr> <td>

allowEventAttribute false

</td> <td>

allowEventAttribute true

</td> </tr> </tbody> </table>

ACTION

insertFormRunElement

Inserts inline form elements such as text fields, text areas, and select boxes at the current caret position.

parameters

NameTypeDescription
typestringThe type of inline form element to insert. <br><br>text<br>number<br>email<br>password<br>hidden<br>radio<br>checkbox<br>textarea<br>select<br>button<br>submit<br>reset<br>label<br>datalist<br>datalistInput
editor.execCommand('insertFormRunElement', type);

insertFormBlockElement

Inserts block form elements such as forms and fieldsets at the current caret position.

parameters

NameTypeDescription
typestringThe type of block form element to insert. <br><br>form<br>fieldset
editor.execCommand('insertFormBlockElement', type);