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
Create new AutoForm component.
Parameters:
params
Name | Type | Description |
---|---|---|
scenario |
type
Scenario |
The scenario to use when binding entities |
details
Methods
- cancelButton ( id )
-
Attach cancel Scenario behaviour to specified button DOM element.
Parameters:
paramsName Type Description id typestringThe id of the button DOM element detailsExample
examples
Back to Topvar form = new AutoForm(firstScenario); form.cancelButton('cancel-btn-id');
- clearBindings ( formId ) → {boolean}
-
Clear existing form bindings. This will clear the _formBindings property on the object.
Parameters:
paramsName Type Description formId typestringThe id of the form DOM element. detailsReturns:returns tableType Description typebooleanWhether the unbind action was successful or not. - loadButton ( id )
-
Attach execute Scenario behaviour to specified button DOM element.
Parameters:
paramsName Type Description id typestringThe id of the button DOM element details - onDataSaved ( callback )
-
Attach a callback that will be called on save of any element associated with this AutoForm instance.
Parameters:
paramsName Type Description callback typeAutoForm~OnDataSavedCallbackCalled when an entity has been successfully updated details - runButton ( id )
-
Attach execute Scenario behaviour to specified button DOM element.
Parameters:
paramsName Type Description id typestringThe id of the button DOM element details - saveButton ( id )
-
Attach save View behaviour to specified button DOM element.
Parameters:
paramsName Type Description id typestringThe id of the button DOM element details
method
method
method
method
method
method
Type Definitions
-
AutoFormElementConfig - {
typeObject }
-
Data structure for a single AutoForm entity definition.details
Properties:
propertiesName Type Argument Description entityName typestringoptional The entity name if this element is an entity. parameterName typestringoptional The parameter name if this is a parameter. indices typeArray.<?>optional Array of indices. editorValidate typeAutoForm~EditorValidationCallbackoptional Callback to validate the element. - EditorValidationCallback ( name, value ) → {Result}
-
Parameters:
paramsName Type Description name typestringEntity name. value type*Value to validate. detailsReturns:returns tableType Description typeResultThe validation result and message if there is an error. - OnDataSavedCallback ( scenario, entity, value )
-
Callback for AutoForm#onDataSaved.
Parameters:
paramsName Type Description scenario typeScenarioThe form's scenario entity typeModelEntityThe form element's entity. Passes undefined if it is an Insight Parameter type value typestring | objectEither 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
members
method
method