Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

DateFieldDefinition renders a calendar that allows the user to select a date and optionally a time.

Info

Date This date field definition is part of the Magnolia 6 UI framework. The fully qualified class name is info.magnolia.ui.field.DateFieldDefinition.

If you work with the Magnolia 5 UI framework, see Date field for Magnolia 5 UI instead.

Table of Contents

Example

...

definition

Code Block
languageyml
date:
  label: Date
  $type: dateField
  type: java.util.Date
  time: true

Date field properties

...

type

required

...

Field properties

Field-specific properties

dateFormat

optional, default is yyyy-MM-dd

Format in which the date is displayed to users. See SimpleDateFormat the DateTimeFormatter class for allowed patterns.

Examples:

Code Block
languagejsyml
dateFormat: yyyy-MM-dd           # 2017-10-31
dateFormat: yyyy-MMMM-dd         # 2017-October-31
dateFormat: EEE, MMM d, yyyy     # Tue, Oct 31, 2017

defaultValue

optional, default is now

Set the default value to a specific date and time such as "2017-10-31" or use the keyword now which defaults to the now for the current date and time . Current time means time at on the host server. Magnolia stores dates and times using server time. The stored time is dates and times are converted and displayed to users in their preferred time zone.

The default value applies only applies to new content items, not to existing content items those that have already been created previously.

(warning) Enclose the default value in Enclose the property value in quotes when using YAML:

Code Block
languagejsyml
defaultValue: "2017-10-31"
defaultValue: "2017-10-31 15:09"

If you define the the dateFormat or  and timeFormat properties then , provide the defaultValue using those the same formats:

Code Block
languagejsyml
dateFormat: MM/dd/yyyy
timeFormat: h:mm a
defaultValue: "10/31/2017 3:09 PM"

time

optional, default is false

Enables time selection. Renders dropdown boxes lists at the bottom of the calendar.

timeFormat

optional, default is HH:mm

Format in which the time is displayed to users. See SimpleDateFormat the DateTimeFormatter class for allowed patterns.

Examples:

Code Block
languagejsyml
timeFormat: HH:mm     # 15:09
timeFormat: h:mm a    # 3:09 PM

Common simple field properties

Include Page
_Common simple field properties
_Common simple
See also Common
field properties
.