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 |
---|---|---|---|---|
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
}); |