{hero}

fields.options

Since: Editor 1.4

List of options for fields which provide options to select from.
Please note - this property requires the Editor extension for DataTables.

The full Editor reference documentation is available to registered users of Editor - the information shown below is a summary only. If you already have an Editor license please , alternatively an Editor license can be purchased on this site, or sign up for the free trial.

Description

When working with field types which provide a list of options that the user can pick from, this parameter provides that ability to set the options available. The built-in field types which make use of this parameter are:

Plug-in field types may also make use of it. Please refer to the plug-in's documentation for details.

The fields.options parameter can be given either as an object, an array of values, or an array of objects.

Array of values

As an array of values, both the value and the label for the field will take the same value (i.e. what the user sees and what is submitted is the same). This is useful for static lists of options, but for data from a joined table, you would typically want to use a different value (i.e. a primary key) from the label.

Array of objects

To have a different value from the label you would typically use an array of objects. By default Editor will look for label and value properties inside the objects, but that can be controlled by the fields.optionsPair parameter.

Object

As an object, the value is taken from the object keys, and the label from the parameter's value.

Other data sources

Although this option makes it possible to set up the options for a field as part of the Editor initialisation (or addition of a field), you can also use the field().update() method to dynamically change the list of options that the user can pick from, or use the options parameter in the JSON uses to populate the DataTable (if you are using its ajax option). This JSON population of data provides the ability to easily get a list of options from a database. See the Editor client / server communication documentation for more details.