nos-forms-jquery

Type

select

Example with all options

{
    "name": "selectExample",
    "id": "myselect",
    "type": "select",
    "label": "Select Example",
    "classname": "form-control",
    "formGroup": true,
    "required": true,
    "autofocus": false,
    "disabled": false,
    "readonly": false,
    "data": {
        "field": 0,
        "testing": 123,
    },
    "title": "Select Example",
    "multiple": false,
    "selected": "", // by setting the selected option to a blank string, we are selecting the blank value in the options object below
    "options": {
        "": "Select One...",
        "value1": "First Value",
        "value2": "Second Value",   // accepts an object or an array of objects
        "value3": "Third Value",
        "value4": "Fourth Value"
    }
}

More practical example

{
    "name": "selectExample",
    "type": "select",
    "label": "Select Example",
    "required": true,
    "selected": "", // by setting the selected option to a blank string, we are selecting the blank value in the options object below
    "options": {
        "": "Select One...",
        "value1": "First Value",
        "value2": "Second Value",   // accepts an object, array, or an array of objects
        "value3": "Third Value",
        "value4": "Fourth Value"
    }
}

Select Options

There are a few ways to enter your select options.

"options": {
    "value1": "First Value",
    "value2": "Second Value"
}
"options": [
    {
        "value1": "First Value"
    },
    {
        "value2": "Second Value"
    }
]
"options": [
    "First Value",
    "Second Value"
]