field().label()

Since: Editor 1.3

Get / set the label for a field.
Please note - this property requires the Editor extension for DataTables.

Description

The field label is the primary piece of information that tells the end user what the data in the field they are entering represents. This is normally as simple as a one or two word string, but can be arbitrarily complex as your form demands. Because of its importance, it is vital that the label be both relevant and concise, and this method provides the ability to modify, or get, the label's value.

The default value can be set when it is initially added to the form using the fields.label option or the label option of the field-options object given to add() when dynamically creating a field. This API method extends that ability by providing a method to set the label value at any point after a field has been added to the form.

Types

field(…).label()

Get the value of the field's label

Returns:

string: The label value

field(…).label( str )

Set the value of the field's label

Parameters:

Returns:

DataTable.Editor.Field: Field instance

Examples

Get the label of a field:

var label = editor.field('name').label();
alert('The name field has a label of: ' + label);

Set the label of a field:

editor.field('name').label('Name: ');