form.converter
FormConverter : d2/sdk/controls/form/form.converter
Form converter. Utility to transform D2 Form metadata.
Extends: Object
- FormConverter :
d2/sdk/controls/form/form.converter
- static
- .convertConfig(formJSON, options) ⇒
ConversionReturnType
- .generateFormModelConfig(formArray, [options]) ⇒
void
- .convertConfig(formJSON, options) ⇒
- inner
- ~ConversionReturnType :
Object
- ~AlpacaSchema :
Object
- ~ConversionReturnType :
- static
FormConverter.convertConfig(formJSON, options) ⇒ ConversionReturnType
Convert a D2 Form metadata into an Alpaca form schema.
Kind: static method of FormConverter
Returns: ConversionReturnType
- propertiesConfig
& signOffConfig
are two separate alpaca form schema to collect properties and user's electronic signature.
Note: Alpaca form schema generated through this method does not have to go through generateFormModelConfig()
method below.
See: Alpaca Forms
Param | Type | Description |
---|---|---|
formJSON | JSON | Raw dialog-like response received from a D2-REST API or an equivalent object constructed literally. |
options | Object | Holder of transformer parameters |
[options.actionMode] | string | How to process the fields. Can be one of 'create', 'read', 'edit'. 'read' is for readonly mode, other two are editable. Value of this option influences the list of fields and their conditions processed as per equivalent D2-config property page field modes. |
[options.layoutMode] | string | By default fields are laid out in a double column fashion, if a single-column is desired instead set this option to 'singleCol'. |
FormConverter.generateFormModelConfig(formArray, [options]) ⇒ void
Inject additional data into an Alpaca form schema and make it compatible for FormModel & FormView. If more than one form is passed in the input, the method also generates cross-reference data if one form uses value from other, for any reason.
Kind: static method of FormConverter
Param | Type | Description |
---|---|---|
formArray | Array.<AlpacaSchema> | Array of Alpaca form schemas. The parameter is also the output parameter, each element in the array is modified with additional data. |
[options] | object | Additional data/control flag used during the conversion. |
[options.initialFieldValueMap] | object | Initial data reference for all the fields across forms. |
FormConverter~ConversionReturnType : Object
Kind: inner typedef of FormConverter
Properties
Name | Type | Description |
---|---|---|
propertiesConfig | Object | Alpaca schema for the main form |
signOffConfig | Object | Alpaca schema for D2 Electronic signature form |
FormConverter~AlpacaSchema : Object
Kind: inner typedef of FormConverter
See: Alpaca Forms
Properties
Name | Type | Description |
---|---|---|
data | object | Object hash of initial values for each field property |
schema | object | Container of schema properties |
schema.properties | object | Object hash defining schema for each field property. |
options | object | Container of additional options |
options.fields | object | Object hash defining options for each field property. |
Example
var form = {
data: {
field1: 'Hello world!'
},
schema: {
properties: {
field1: {
type: 'string',
required: true
}
}
},
options: {
fields: {
field1: {
type: 'text',
label: 'Greetings'
}
}
}
};