field().message()
Get / set a dynamic information message for the field.
Please note - this property requires the Editor extension for DataTables.
Description
It can often be helpful to end users if fields, particularly complex fields, have information messages either explaining what the data in the field represents, or how a particular input control operates. This method provides the ability to set and clear such an information message for fields.
A field message can be set when it is initially added to the form using the fields.message option. This API method extends that ability by providing a method to get and set the field information message any point after a field has been added to the form.
Editor provides three different elements for information display in each field, which can be used independently of each other, or in conjunction as required by your user interface design:
fields.message/field().message(): Dynamic information about a field that is typically updated based on user input. This is shown below the field's user input area.fields.fieldInfo/field().fieldInfo(): Very similar to the message option, but typically used for static information about an input - e.g. explaining what format is expected, or what the input value is used for.fields.labelInfo/field().labelInfo(): Information message shown below the field'slabelelement.
Note that the message() method also provides the ability to show and hide an information message for a specific field, and also extends that ability to being able to set a form level information message. For field messages, these two methods can often be used interchangeably. The key difference is in the return value - this method will return a DataTable.Editor.Field instance, while the message() method returns a DataTable.Editor instance. This can effect how you chain methods if you are using the returned value for chaining.
Types
field(…).message()
field(…).message( msg )
Set the information message for the field
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | msg | No | |
Information message to show in the form. To remove an existing message, pass in an empty string ( Additionally, since Editor 1.5, a function can be given as the message, which will be executed by Editor with the returned value being used as the message to display. The function is passed two parameters:
| |||
Returns:
DataTable.Editor.Field: Field instance
Examples
Show a message for an individual field when a 'help' icon is clicked on:
$('#user_help').click(function () {
editor
.field('user')
.message('The user name is what the system user will login with');
});Clear an information message:
editor.field('user').message('');Related
The following options are directly related and may also be useful in your application development.