The date field input widget allows for the capturing of data for both date and datetime types.
The widget allows for binding to a basic data type variable directly or to an object instance attribute.
The appearance of the widget is slightly altered depending on the type of variable that it is bound to. For date types a calendar will be presented from which to select a date. For datetime types two additional fields for the hour and minute is presented in addition to the calendar.
The title is specified as a key to a lang file entry and is required. Visibility bindings are also supported.
Example
Binding to a datetime type
The abbreviated code snippets and screenshot below shows the use of <datefield/> with a value binding to an object instance attribute that has a datetime type.
Model object attribute
persistent object Farmer {
.
.
// What day and time did the farmer last visit a shop
datetime lastShopVisit;
.
.
}
<datefield> bound to datetime type example screenshots
Binding to a date type
The abbreviated code snippets and screenshot below shows the use of <datefield/> with a value binding to an object instance attribute that has a date type.
Notice from the above code snippet how Mez:now is used to set an initial value for the selectedDateOfStocktake variable is set in the init function. If the init function is specified in the view, this initial value will be set when the view load and will be displayed in the widget.
en.lang file entry
select.date_of_stocktake = Date of Stocktake:
<datefield> bound to date type example screenshots
Add Comment