Skip to main content

Date Widget

The Date widget provides a comprehensive date and time selection interface with multiple display formats and configuration options. It supports single dates, date ranges, time selection, and various validation rules.

Widget OverviewDirect link to Widget Overview

The Date widget is built on Element UI's date picker component and offers flexible date/time input capabilities with extensive customization options including format specification, validation rules, and dynamic behavior.

Date Widget

Configuration OptionsDirect link to Configuration Options

Global SettingsDirect link to Global Settings

Name

  • Field: Name
  • Description: Display label for the date widget
  • Type: Text input
  • Required: Yes

Variable/Model

  • Field: Variable/Model
  • Description: The data model property that will store the selected date value
  • Type: Text input
  • Required: Yes
  • Note: Must be a unique identifier within the form scope

Default Value

  • Field: Default Value
  • Description: Initial value for the date widget
  • Type: The same field and large editor as the Input widget, with the placeholder YYYY-MM-DD or =formula
  • Supports:
    • Static dates: 2023-12-25
    • Dynamic expressions: {{currentDate}}, ${today}
    • Relative dates: =moment().add(7, "days").toDate() (a formula starts with =; {{ }} only reads a page variable, so {{moment()}} does not work)
  • Suggestions: Ready-made formulas (Today, In a few days, A few days ago, Start of the month, End of the month, From another field, Fixed day). There is no suggestion on the connected user
  • Writing a day: A day is written 2023-12-25. 25/12/2023 is read as a division: a message says so under the field, and Fix in the large editor changes it to 2023-12-25
  • Ending a formula: A moment formula has to end with .toDate(), or with .format(…) when Date Only is on and the field stores the date as text. A message flags the wrong ending, and Fix writes the right one

Date Function

  • Field: Date function
  • Description: Custom JavaScript function to control date picker behavior
  • Type: Text input
  • Usage: Define custom date restrictions or calculations
  • Example: return { disabledDate: (time) => time.getTime() < Date.now() }

Show Type

  • Field: Show Type
  • Description: Determines the date picker display format and selection mode
  • Type: Dropdown selection
  • Options:
    • year - Year selection only
    • month - Month selection only
    • date - Single date selection
    • dates - Multiple date selection
    • datetime - Date and time selection
    • datetimerange - Date and time range selection
    • daterange - Date range selection
  • Default: date

Date Only

  • Field: Date Only
  • Description: When enabled, the value is stored as text, formatted with the Format below (for example 2023-12-25), instead of a date
  • Type: Toggle switch
  • Default: false

Clearable

  • Field: Clearable
  • Description: Allows users to clear the selected date
  • Type: Toggle switch
  • Default: true

Format

  • Field: Format
  • Description: Date/time display format using moment.js format strings
  • Type: Text input
  • Examples:
    • YYYY-MM-DD - 2023-12-25
    • DD/MM/YYYY - 25/12/2023
    • YYYY-MM-DD HH:mm:ss - 2023-12-25 14:30:00
    • MMM DD, YYYY - Dec 25, 2023
Date Global Settings

ValidationDirect link to Validation

Screen-Based ValidationDirect link to Screen-Based Validation

Configure widget behavior across different screens (mobile, tablet, desktop):

Available

  • Controls whether the widget is available on specific screen types
  • Type: Toggle switch per screen

Visible

  • Controls widget visibility on specific screen types
  • Type: Toggle switch or advanced expression
  • Advanced: Use JavaScript expressions like {{user.role === 'admin'}}

Required

  • Makes the field mandatory on specific screen types
  • Type: Toggle switch or advanced expression
  • Validation: Triggers form validation if empty

Disable

  • Disables user interaction on specific screen types
  • Type: Toggle switch or advanced expression
Date Validation

Validation RulesDirect link to Validation Rules

Custom Rules

  • Purpose: Define specific validation criteria
  • Configuration:
    • Rule Type: Select from predefined rule types
    • Value: Rule parameter (if applicable)
    • Message: Custom error message
  • Examples:
    • Minimum date validation
    • Maximum date validation
    • Custom date range validation
Date Custom Rules

ActionsDirect link to Actions

On Click

  • Field: On click
  • Description: JavaScript code executed when date selection changes
  • Type: Code editor or action builder
  • Context Variables:
    • SF_input.value - Selected date value
    • SF_input.SF_currentIndex - Current loop index (if in a loop)
  • Example: console.log('Date selected:', SF_input.value)
Date [Actions](/docs/en/ressources/project/web-interface/actions)

Style ConfigurationDirect link to Style Configuration

Placeholder

  • Field: Placeholder
  • Description: Placeholder text displayed when no date is selected
  • Type: Text input
  • Example: "Select a date"

Width

  • Field: Width
  • Description: Widget width specification
  • Type: Text input
  • Examples: 100%, 300px, 50rem

Class Names

  • Field: Class
  • Description: Custom CSS classes for styling
  • Type: Text input with dynamic class support
  • Examples: custom-date-picker, highlighted-field

Dynamic Classes

  • Purpose: Apply conditional CSS classes based on data
  • Configuration: Use the paint brush button for advanced class configuration
  • Example: Apply different styles based on selected date validity
Date Style Configuration

How Dates Without Time Are StoredDirect link to How Dates Without Time Are Stored

When the picker has no time (Show Type date, dates, daterange, month or year) and Date Only is off, the chosen day is stored as a real date at 12:00 UTC of that day. For example, picking December 25, 2023 stores 2023-12-25T12:00:00.000Z, whatever the time zone of the user.

  • The same day is shown on every computer from UTC-11 to UTC+11 and on the server: a day no longer moves to the previous day in reports, collections, filters or PDFs, as it could when the day was stored at local midnight.
  • Static default values (2023-12-25) and dynamic ones (for example =moment().toDate()) are stored the same way.
  • The value stays a date: sorting, range filters and date comparisons keep working. On the server, value.toISOString().slice(0, 10) gives the day.
  • Values saved before this rule (local midnight) are shown and kept as they are until a user picks a new day.
  • Unchanged: pickers with a time (datetime, datetimerange) and the Date Only text mode.

Usage ExamplesDirect link to Usage Examples

Basic Date SelectionDirect link to Basic Date Selection

Date Basic Date Selection

Date Range SelectionDirect link to Date Range Selection

Date Range Selection

Dynamic Default ValuesDirect link to Dynamic Default Values

A variable or a formula in Default Value is computed when the page opens, then again each time one of its variables changes: the new date replaces the one the user chose. See Input › Default Value.

Date Dynamic Default Values

Advanced FeaturesDirect link to Advanced Features

Conditional VisibilityDirect link to Conditional Visibility

Configure the widget to show/hide based on other form values:

Date Conditional Visibility

Best PracticesDirect link to Best Practices

  1. Format Consistency: Use consistent date formats across your application
  2. Validation: Always validate date inputs, especially for business-critical dates
  3. User Experience: Provide clear placeholders and labels
  4. Accessibility: Ensure proper labeling for screen readers
  5. Mobile Optimization: Consider different date picker behaviors for mobile devices
  6. Default Values: Use sensible defaults to improve user experience
  7. Range Validation: For date ranges, ensure start date is before end date

TroubleshootingDirect link to Troubleshooting

Common IssuesDirect link to Common Issues

Date not saving correctly

  • Check the format configuration matches your backend expectations
  • Verify the model name is unique and properly defined
  • A day without time is stored at 12:00 UTC (see How Dates Without Time Are Stored): compare days, not exact times

Validation not working

  • Ensure required rules are properly configured
  • Check that validation messages are defined

Date picker not appearing

  • Verify the widget is set to visible on the current screen type
  • Check for CSS conflicts that might hide the picker

Format display issues

  • Confirm the format string follows moment.js conventions
  • Test format strings with sample dates

Debug TipsDirect link to Debug Tips

  1. Use browser developer tools to inspect the generated HTML
  2. Check console for JavaScript errors
  3. Verify data model values in Vue DevTools
  4. Test different screen sizes and orientations