Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Supported opCharts Components


Code Block
languagejs
titleconf/form_schema/opCharts_demo.json
{
    "label": "Demo",
    "description": "Demo form schema",
    "component": ["element_lists"],
    "tags": ["inventory"],
    "schema": {
        "demo1": {
            "label": "My Label",
            "type": "Text"
        },
        "demo2": {
            "label": "Another Label",
            "type": "Select",
            "options": ["option1", "option2"]
        }
    }
}

...

Part of the filename will be saved to schema documents so changing the filename at a later data date will break linkage.

Form Metadata

keytyperequireddescription
labelStringyesTitle of the form schema which will be shown in the gui
descriptionStringnoGive context to your users about what this form is for
componentarray[string]noAllow the form schema to show for different components, is an array so a form could be shared over more than one component, if this is not defined then it will show over more than type of component.
tagsarray[string]noWe use this in element_inventory to then filter down form types for different inventory, its an array so you can share this form over multiple types of inventory.
schemaobjectyesDeep structure to represent the form
schema.<key>nested keyyesDefines what the value will be saved under
schema.<key>.typestringnoDefines the type of field type to be rendered, if not defined it will default to Text
schema.<key>.titlestringnoDefines the text that appears in a form field's label
schema.<key>.helpstringnoHelp text to add next to the editor.
schema.<key>.validatorsarray[]noA list of validators, see validation below


Supported Field Types

Schema Value
Text
Number
Password
TextArea
Checkbox
Select
Radio
Date
DateTime


Validation

typedescription
requiredChecks the field has been filled in.
numberChecks it is a number, allowing a decimal point and negative values.
rangeChecks it is a number in a range defined by min and max options. Message if it is not a number can be set with the numberMessage option.
emailChecks it is a valid email address.
urlChecks it is a valid URL.
matchChecks that the field matches another. The other field name must be set in the field option.
regexpRuns a regular expression. Requires the regexp option, which takes a compiled regular expression or a string value. Setting the match option to false ensures that the regexp does NOT pass.

See Backbone Form Validation for examples and further docs.

...