Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: MOTION-157

...

Date field properties

Simple date field

mgnl-n
form
Localtab Group
Localtab
activetrue
titleYAML file
Code Block
languagejs
form:
  tabs:
    - name: tabText
      label: Text
      fields:
        - name: date
          fieldType: date
          time: false
          type: Date
          label: Date
          defaultValue: now

Localtab
titleJCR node
Advanced Tables - Table Plus
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

Node name

Value

Mgnl n
tabs

Mgnl n
tabText

Mgnl n
fields

Mgnl n
date

Mgnl p
fieldType

date

Mgnl p
time

false

Mgnl p
type

Date

Mgnl p
label

Date

Mgnl p
defaultValue

now

Include Page
_referencing Referencing fields shortcut info - 5 UI
_referencing Referencing fields shortcut info - 5 UI

Field-specific properties:

<field name>

type

required

Set the type property to Date to ensure that the value is saved as a Calendar object and not a String. The addition of this property is essential.

dateFormat

optional, default is yyyy-MM-dd

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

Examples:

Code Block
languagejs
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 such as "2017-10-31" or use the keyword now which defaults to the current date and time. Current time means time at the host server. Magnolia stores dates and times using server time. The stored time is converted and displayed to users in their preferred time zone.

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

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

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

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

Code Block
languagejs
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 at the bottom of the calendar.

timeFormat

optional, default is HH:mm

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

Examples:

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

Common field properties:

Include Page
_Common field properties - 5 UI
_Common field properties - 5 UI