Initializing help system before first use

AutoForm

Bind elements in an HTML form to model entities in a Scenario. An input form element can be linked with a scalar, parameter or one element of an array. Also provides pre-defined button handlers for common button actions.

Method summary

name description
cancelButton Attach cancel Scenario behaviour to specified button DOM element.
clearBindings Clear existing form bindings.
loadButton Attach execute Scenario behaviour to specified button DOM element.
onDataSaved Attach a callback on data saving completion.
runButton Attach execute Scenario behaviour to specified button DOM element.
saveButton Attach save View behaviour to specified button DOM element.
constructor

Constructor

new AutoForm ( scenario )

Create new AutoForm component.

Parameters:
params
Name Type Description
scenario
type
Scenario
The scenario to use when binding entities
details

Methods

method
cancelButton ( id )

Attach cancel Scenario behaviour to specified button DOM element.

Parameters:
params
Name Type Description
id
type
string
The id of the button DOM element
details
Example
examples
var form = new AutoForm(firstScenario);
form.cancelButton('cancel-btn-id');
Back to Top
method
clearBindings ( formId ) → {boolean}

Clear existing form bindings. This will clear the _formBindings property on the object.

Parameters:
params
Name Type Description
formId
type
string
The id of the form DOM element.
details
Returns:
returns table
Type Description
type
boolean
Whether the unbind action was successful or not.
Back to Top
method
loadButton ( id )

Attach execute Scenario behaviour to specified button DOM element.

Parameters:
params
Name Type Description
id
type
string
The id of the button DOM element
details
Back to Top
method
onDataSaved ( callback )

Attach a callback that will be called on save of any element associated with this AutoForm instance.

Parameters:
params
Name Type Description
callback
type
AutoForm~OnDataSavedCallback
Called when an entity has been successfully updated
details
Back to Top
method
runButton ( id )

Attach execute Scenario behaviour to specified button DOM element.

Parameters:
params
Name Type Description
id
type
string
The id of the button DOM element
details
Back to Top
method
saveButton ( id )

Attach save View behaviour to specified button DOM element.

Parameters:
params
Name Type Description
id
type
string
The id of the button DOM element
details
Back to Top

Type Definitions

members
AutoFormElementConfig - {
type
Object }
Data structure for a single AutoForm entity definition.
details
Properties:
properties
Name Type Argument Description
entityName
type
string
optional  The entity name if this element is an entity.
parameterName
type
string
optional  The parameter name if this is a parameter.
indices
type
Array.<?>
optional  Array of indices.
editorValidate
type
AutoForm~EditorValidationCallback
optional  Callback to validate the element.
method
EditorValidationCallback ( name, value ) → {Result}
Parameters:
params
Name Type Description
name
type
string
Entity name.
value
type
*
Value to validate.
details
Returns:
returns table
Type Description
type
Result
The validation result and message if there is an error.
Back to Top
method
OnDataSavedCallback ( scenario, entity, value )

Callback for AutoForm#onDataSaved.

Parameters:
params
Name Type Description
scenario
type
Scenario
The form's scenario
entity
type
ModelEntity
The form element's entity. Passes undefined if it is an Insight Parameter type
value
type
string | object
Either a single value string or a composite key-value pair, in the case of an array) for the value saved. If removal of an array element then the value will be an empty string
details
Back to Top