# Class: Select

## jala.Form.Component.Select(name)

Subclass of jala.Form.Component.Input which renders and validates a dropdown element.

## Constructor

#### new Select(name)

Constructs a new Select component instance

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | Name of the component, used as name of the html controls.

Source:
  - jala/code/Form.js, line 1911

##### Returns:

A newly created Select component

### Methods

#### checkOptions(reqData)

Checks user input for optiongroups: Unless require("checkoptions") has ben set to false, the user input must exist in the option array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`reqData` | Object | request data

Source:
  - jala/code/Form.js, line 2014

##### Returns:

null if everything is ok or string containing error message

#### checkRequirements(reqData)

Validates user input from a dropdown element by making sure that the option value list contains the user input.

##### Parameters:

Name | Type | Description
--- | --- | ---
`reqData` | Object | request data

Source:
  - jala/code/Form.js, line 1983
See:
  - jala.Form.Component.Select#checkOptions

##### Returns:

string containing error message or null if everything is ok.

#### getFirstOption()

Returns the text that should be displayed if no value is selected.

Source:
  - jala/code/Form.js, line 1944

#### getOptions()

Returns the option list for this component.

Source:
  - jala/code/Form.js, line 1919

#### parseOptions()

Creates an array of options for a dropdown element or a group of radiobuttons. If options field of this element's config is an array, that array is returned. If options is a function, its return value is returned.

Source:
  - jala/code/Form.js, line 1995

##### Returns:

array of options

#### renderControls(attr, value, reqData)

Renders a dropdown element to the response.

##### Parameters:

Name | Type | Description
--- | --- | ---
`attr` | Object | Basic attributes for this element.
`value` | Object | Value to be used for rendering this element.
`reqData` | Object | Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured.

Source:
  - jala/code/Form.js, line 1969

#### setFirstOption(newFirstOption)

Sets the text that is displayed if no value is selected

##### Parameters:

Name | Type | Description
--- | --- | ---
`newFirstOption` | String | text to display as first option element.

Source:
  - jala/code/Form.js, line 1952

#### setOptions(newOptions)

Sets the option list for this component. The argument may either be an array that will be used as option list, or a function that is called when the option component is rendered and has to return an option array. For both arrays those formats are allowed:
- Array of arrays `[ [val, display], [val, display], .. ]`
- Array of objects `[ {value:val, display:display}, .. ]`
- Array of strings `[ display, display, .. ]` In this case, the index position of the string will be the value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`newOptions` | Array | function | Array or function defining option list.

Source:
  - jala/code/Form.js, line 1935