{hero}

field-options

Field configuration options common to all field types.
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

The Editor fields initialisation option and add() method both provide the ability to add fields to an Editor instance, with the options for the field defined in an object of this type (field-options). This data type defines the default set of options that are common to all field types and can be used equally in either method of adding fields to the form.

Note that field types can support additional options beyond those defined in this data type - for example the select field type supports an options options for listing the values that can be selected. Please refer to the documentation for each individual field for information on any additional options they support. As noted, the options documented here are supported by all fields.

Options

The field options are properties in a standard Javascript object. The following properties are supported:

  • string className - Class name to add to the field container. See fields.className for additional information and full usage instructions.
  • string or function data - Data property from the data source object to use as the data for the field. See fields.data for additional information and full usage instructions.
  • string or function def - Default value for the field to take. See fields.def for additional information and full usage instructions.
  • string fieldInfo - Information text that is shown below the input control. See fields.fieldInfo for additional information and full usage instructions.
  • string id - Field ID. See fields.id for additional information and full usage instructions.
  • string label - Label to display for the field input. See fields.label for additional information and full usage instructions.
  • string labelInfo - Information text that is shown below the field label. See fields.labelInfo for additional information and full usage instructions.
  • string name - Unique name of the field - sent to the server on form submission. See fields.name for additional information and full usage instructions.
  • string type - Field input type. See fields.type for additional information and full usage instructions.
Simple initialisation of a field using fields:
var editor = new $.fn.Editor( {
    ajax:   "php/staff.php",
    table:  "#myTable",
    fields: [
        {
            label: "First name:",
            name: "first_name"
        }
    ]
} );
Simple initialisation of a field using add():
var editor = new $.fn.Editor( {
    ajax:   "php/staff.php",
    table:  "#myTable"
} );

editor.add( {
    label: "First name:",
    name: "first_name"
} );
Using multiple options in a field type:
var editor = new $.fn.Editor( {
    ajax:   "php/staff.php",
    table:  "#myTable",
    fields: [
        {
            label: "Appointment date:",
            name: "apptDate",
            type: "date",
            fieldInfo: "Enter the appointment date using the options above",
            def: function () {
                return new Date()
            }
        }
    ]
} );