The date field.

The Date Field uses the Bootstrap Datetime picker under the hood. You can learn more about the picker at it's GitHub project page:

For more information on date and time formatting strings, see the Moment.js documentation:

With this control, you can pass any of the bootstrap-datetimepicker options information through to the underlying control via the options.picker setting.


TitleDate Field
DescriptionDate Field
JSON Schema Type(s)string
Field Typedate
Base Field Typetext


defaultanyThe default value to be assigned for this property. If the data for the field is empty or not provided, this default value will be plugged in for you. Specify a default value when you want to pre-populate the field's value ahead of time.
dependenciesarrayList of property dependencies.
descriptionstringDetailed description of the property.
disallowarrayList of disallowed values for the property.
enumarrayList of specific values for this property
formatstringdateProperty data format
maxLengthnumberMaximum length of the property value.
minLengthnumberMinimal length of the property value.
patternstringRegular expression for the property value.
readonlybooleanIndicates that the field is read-only. A read-only field cannot have it's value changed. Read-only fields render in a grayed-out or disabled control. If the field is rendered using a view with the displayReadonly attribute set to false, the read-only field will not appear.
requiredbooleanIndicates whether the field's value is required. If set to true, the field must take on a valid value and cannnot be left empty or unassigned.
titlestringShort description of the property.
typestringstringData type of the property.


allowOptionalEmptyAllows this non-required field to validate when the value is empty
autocompletestringAllows you to specify the autocomplete attribute for the underlying input control whether or not field should have autocomplete enabled.
dataobjectAllows you to specify a key/value map of data attributes that will be added as DOM attribuets for the underlying input control. The data attributes will be added as data-{name}='{value}'.
dateFormatstringDate format (using moment.js format)
disabledbooleanField will be disabled if true.
disallowEmptySpacesbooleanWhether to disallow the entry of empty spaces in the text
disallowOnlyEmptySpacesbooleanWhether to disallow the entry of only empty spaces in the text
fieldClassstringSpecifies one or more CSS classes that should be applied to the dom element for this field once it is rendered. Supports a single value, comma-delimited values, space-delimited values or values passed in as an array.
focuscheckboxtrueIf true, the initial focus for the form will be set to the first child element (usually the first field in the form). If a field name or path is provided, then the specified child field will receive focus. For example, you might set focus to 'name' (selecting the 'name' field) or you might set it to 'client/name' which picks the 'name' field on the 'client' object.
formobjectOptions for rendering the FORM tag.
helperstringField help message.
helpersarrayAn array of field help messages. Each message will be displayed on it's own line.
hiddenbooleanField will be hidden if true.
hideInitValidationErrorbooleanHide initial validation errors if true.
idstringUnique field id. Auto-generated if not provided.
inputTypestringAllows for the override of the underlying HTML5 input type. If not specified, an assumed value is provided based on the kind of input control (i.e. 'text', 'date', 'email' and so forth)
labelstringField label.
maskStringstringExpression for the field mask. Field masking will be enabled if not empty.
namestringField Name.
optionLabelsarrayAn array of string labels for items in the enum array
pickeranyOptions that are supported by the Bootstrap DateTime Picker.
placeholderstringField placeholder.
readonlybooleanField will be readonly if true.
showMessagesbooleantrueDisplay validation messages if true.
sizenumber40Field size.
sortfunctionDefines an f(a,b) sort function for the array of enumerated values [{text, value}]. This is used to sort enum and optionLabels as well as results that come back from any data sources (for select and radio controls). By default the items are sorted alphabetically. Don't apply any sorting if false.
typestringdateField type.
typeaheadProvides configuration for the $.typeahead plugin if it is available. For full configuration options, see:
validatebooleantrueField validation is required if true.
viewstringAllows for this field to be rendered with a different view (such as 'display' or 'create')

Example 1

This is the simplest way that you can render a date. It's driven purely off of JSON schema and uses the format schema setting to specify that the value should be a date. Alpaca renders a date field by default and assumes the American format of MM/DD/YYYY.

Example 2

You can select a different date format using the moment.js formatting options. In this example, we switch to using a simplified European date format of DD/MM/YY. Here we also skip the schema.format method and specifically spell out that we'd like a date field control. The format is passed to the underlying DateTimePicker control directly via the picker option.

In addition, the manualEntry option is set to false to prevent manual entry of date values into the text field. The picker is therefore required to enter the date.

Example 3

Date fields participate in the validation chain along with everything else.

Here is an example of a date field that is invalid. By default, the date format is MM/DD/YYYY. As such, the validation check will determine that the value of this date field is invalid.

The hideInitValidationError setting is provided but it isn't necessary since it defaults to false anyway for editable views. You can set it to true to hide the initial validation message.

Example 4

You can specify custom date formats as well using the dateFormat option. Here we specify a European date format and also explicitly say that we want a date field (as opposed to having Alpaca figure that out from the schema format).

Example 5

Here we use the bootstrap-display view to tell Alpaca to render a set of fields in a display-only mode. Nothing is editable, including the date.

Example 6

If you'd like to customize the behavior of this control, you can pass in explicit configuration via the picker option. Take a look at all of the available options on the Bootstrap DateTime Picker plugin page.

Here is an example that limits the calendar. The minimum date is two weeks ago. The maximum date is two weeks from now. And we switch the language to Spanish.

© 2016 Gitana Software, Inc.

Alpaca is sponsored by