{hero}

field().def()

Since: Editor 1.3

Get / set the default value of the field.
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 default value of a field is used by the create() command for each field in the form, and when editing a field (edit(), bubble() and inline() if the field's value at the time of editing is undefined). The form fields are automatically filled in with the default values in these circumstances.

The default value can be set when it is initially added to the form using the fields.def option or the def 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 default value at any point after a field has been added to the form.

Default values can be given as any Javascript data type (numbers, strings, objects, etc), including functions. If given in this form, the function will be evaluated when the default value is requested, and the value returned used. This can be useful, for example, to set the current date as the default in a date input field, since the function is evaluated when requested.