<datefield/>


Description

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. A tooltip can also be specified as a key to a lang file entry but is optional. 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;
    .
    .
}
View XML
<datefield label="datefield.last_shop_visit">
    <binding variable="farmer">
        <attribute name="lastShopVisit"/>
    </binding>
</datefield>
Backing unit
Farmer farmer;

void init() {
    farmer = Farmer:new();
    .
    .
}
en.lang file entry
 datefield.last_shop_visit = Last shop visit:

<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.

View XML
 <datefield label="datefield.date_of_stocktake">
    <binding variable="selectedDateOfStocktake"/>
</datefield>
Backing unit
date selectedDateOfStocktake;

void init() {
    .
    .
    selectedDateOfStocktake = Mez:now();
}

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 loads 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

 




Additional Mentions and References