field().label()
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()
field(…).label( str )
Set the value of the field's label
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | str | No | |
Set the label for the field. This can include HTML which will be rendered directly into the field's label element. | |||
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: ');