<datefield/>
- Jacques Marais
- jcrowther
- Former user (Deleted)
- Former user (Deleted)
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.
A new addition in version 1.57.0 (specific to the new UI) is the description
attribute. The description attribute works similarly to the title in that it is specified as a key to a lang file entry, however, its purpose is to allow for additional information related to an input and will appear beneath the input.
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.
persistent object Farmer { . . // What day and time did the farmer last visit a shop datetime lastShopVisit; . . }
<datefield label="datefield.last_shop_visit"> <binding variable="farmer"> <attribute name="lastShopVisit"/> </binding> </datefield>
Farmer farmer; void init() { farmer = Farmer:new(); . . }
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.
<datefield label="datefield.date_of_stocktake"> <binding variable="selectedDateOfStocktake"/> </datefield>
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.
select.date_of_stocktake = Date of Stocktake:
<datefield> bound to date type example screenshots
Additional Mentions and References
- Devoted section in the Helium Tutorial Lesson 7: Dynamic Tables
- Helium DSL and View Quick Reference