Phone API Reference - UI Extended - genericForm.show

Phone API Reference - UI Extended - genericForm.show

genericForm.show

 

Description

Clears anything currently on the screen and shows the form.

Basic Example: 

 genericForm.show(parameters);

 

List of genericForm inputTypes:

  • normal: Basic Input UI Widget

  • textCycler: TextCycler Extended Class

  • selectInput: SelectInput Extended Class

  • hostInput: Group of inputs that all input hostname or ip address

Parameters

Name

Required

Type

Default

Description

Name

Required

Type

Default

Description

id

Yes

string

 

Identifier for the form instance.

inputs

Yes

 

 

List of inputs to display on the form. The following are possible parameters: textCycler, hostInput, selectInput, normal/numeric, text.

 

{"text" : "", "setting" : "", "inputType" : "", "inputParams" : {}}

labelWidth

Yes

integer

 

Width of the label for each field.

object

Yes

object

 

Object containing the submit, back, and (optionally) validation functions.

title

Yes

string

 

Title text to display.

values

Yes

object

 

Default values for the form objects. Each value is keyed to the name of an input.

onkeyline1

No

function

 

Callback function for when the user presses the 'line 1' hard button.

onkeycancel

No

function

 

Callback function for when the user presses the cancel hard button.

forceRedraw

No

boolean

 

Forces all widgets to be redrawn. Without this parameter, if the form has already been shown, it will display the widgets in the state they were last displayed.

validate

No

string

 

Regular expression to compare the field's value before form submission. If the value does not match, the 'errorMsg' property will be displayed, and the user will be sent back to the form to correct the value.

errorMsg

No

string

 

Message to display to the user if the field does not match the 'validate' regEx.

Examples

genericForm.show containing each of the possible input types can be created as follows:

var app = require('app'); app.init();    var genericForm = require('genericForm'); //The array of input items to use in the form var items = [ {     'text'      : 'sample TextCycler',     'setting'   : 'sample_textCycler',     'inputType' : 'textCycler',     'inputParams'   : {         'options'   : [             {'display' : 'textCycler1', 'value' : 1},             {'display' : 'textCycler2', 'value' : 2}         ]       } }, {     'text'      : 'sample hostInput',     'setting'   : 'sample_hostInput',     'inputType' : 'hostInput',     'inputParams'   : {         'showDotSoftkey'        : true,         'allowInputTypeChange'  : true     } }, {     'text'      : 'sample selectInput',     'setting'   : 'sample_selectInput',     'inputType' : 'selectInput',     'inputParams'   : {         'title'         : 'sample title',         'softkeyLabel'      : 'softkey',         'softkeyCallback'   : function () { }, //callback goes here         'options'       : [             {'display' : 'selectInput1', 'value' : 1},             {'display' : 'selectInput2', 'value' : 2}         ]       } }, {     'text'      : 'sample normalInput',     'setting'   : 'sample_normalInput',     'inputType' : 'normal',  //'numeric' inputType makes a similar input widget     'validate'  : '[a-z]+[0-9]+', //require at least one letter followed by at least one digit     'errorMsg'  : 'normalInput must contain a letter followed by a number',     'inputParams'   : {} }, {     'text'      : 'sample text',     'setting'   : 'sample_text',     'inputType' : 'text',     'inputParams'   : {} } ];    //The form is constructed and shown: genericForm.show({     'id'        : 'exampleForm',     'labelWidth'    : (digium.phoneModel === 'D70') ? 140 : 125,     'values'    : {         'sample_textCycler' : 1,         'sample_hostInput'  : '192.168.1.1',         'sample_selectInput'    : 2,         'sample_normalInput'    : 'Some Text',         'sample_text'       : 'This is a text input'     },     'inputs'    : items,     'object'    : this,     'title'     : 'Sample Form',     'onkeyline1'    : digium.background,     'onkeycancel'   : digium.background,     'forceRedraw'   : true });

Return to Documentation Home I Return to Sangoma Support