The SCRIPTBUTTON helper generates a button with the same markup as the script button field type. It's useful if you need to insert a button into your template or dynamically set button attributes.
Parameters
{{SCRIPTBUTTON name="testbutton" label=this.description index=@index data="example" onClick="clickFunc" class="application" extraClass="remove"}}
Name | Description |
---|---|
name | Used to make up the button's name and id. Defaults to "SCRIPTBUTTON". The index will be automatically appended where applicable. The id will prepend the form name to this value (separated by an underscore), for consistency with iCM form fields, eg MYFORM_SCRIPTBUTTON1 |
label | The button's label. Defaults to "Press" |
index | An optional index that will be appended to the button's name to generate the id/name attribute values. Needed when iterating over collections to generate multiple buttons, in which case @index can be used |
onClick | The name of the function to call when the button is clicked. For example The function will be automatically be passed the form helper, button name, index and any custom data (see the data parameter) as its arguments. Alternatively the actual JavaScript (for example, The onClick attribute value of the generated input element calls an auto-created id_onClick function that in turn calls the function whose name has been set via this parameter. |
data | Any additional data that should be passed through to the function (as the last argument) of the onClick parameter. This data can be a simple value When in a loop, the "this" object may be used to pass through data about the current item, for example |
class | Defaults to "script" matching the standard script buttons. Added to the outer div and to the input with a prefix of "icminput--". The standard button classes (used by the various button field types) are reset, save, submit, next, back |
extraClass | An optional additional class that will be applied to the input with an "icminput--" prefix. For example "contrast" will add the class "icminput--contrast" to the input. Contrast is a standard class, others will need to be styled by your site's CSS |
Additional Notes
The SCRIPTBUTTON helper registers the button with the form runtime, so that the standard helper methods (helper.focusField, hideField, disableField, etc) can be called on any button created using it.
Handlebars sub-expressions can be used for any of the attributes, but their result must make up the entirety of the parameter value. So
Button Examples
You can download these examples from the Downloads section on this page.