Date API
Per-option reference for the Date field; see the Date guide for tasks and examples.
Options are passed to the field declaration in a resource's fields method, for example in app/avo/resources/user.rb:
field :birthday, as: :date, format: "yyyy-LL-dd"Shared options such as placeholder and link_to_record are covered in common field options.
Date formatting
-> format
The date format used on index and show pages. Uses Luxon formatting tokens.
field :birthday, as: :date, format: "dd LLL yyyy"- Type:
String - Default:
"yyyy-LL-dd"
-> picker_format
The visible date format on new and edit forms. Uses flatpickr formatting tokens, independently of the index and show format.
field :birthday, as: :date, picker_format: "F J Y"- Type:
String - Default:
"Y-m-d"
Calendar behavior
-> first_day_of_week
The first weekday in the picker calendar, following flatpickr's localization.
field :birthday, as: :date, first_day_of_week: 0| Value | Behavior |
|---|---|
0 | Sunday first |
1 | Monday first |
2 | Tuesday first |
3 | Wednesday first |
4 | Thursday first |
5 | Friday first |
6 | Saturday first |
- Type:
Integer - Default:
1 - Values:
0through6 - Validation: Avo does not validate the weekday range before forwarding it to flatpickr.
-> picker_options
Additional flatpickr options. Avo supplies weekday and month names from the app locale and merges a supplied locale Hash over those names.
field :birthday, as: :date, picker_options: {maxDate: "today"}- Type:
Hashwith JSON-serializable flatpickr options - Default:
{} - Validation: Avo does not validate flatpickr option names or values.
Option precedence
Avo sets altFormat, disableMobile, locale.firstDayOfWeek, enableTime, enableSeconds, and noCalendar after applying picker_options, so those entries cannot override Avo's settings. An existing field value also takes precedence over defaultDate. The locale override must be an object, not a flatpickr locale name string.
-> disable_mobile
Disables flatpickr's native mobile picker fallback, rather than disabling flatpickr itself.
field :birthday, as: :date, disable_mobile: true| Value | Behavior |
|---|---|
false | Allows a native mobile picker when flatpickr supports it |
true | Uses flatpickr on mobile too |
- Type:
Boolean - Default:
false