Skip to content
How-to guides and worked examplesSee the guides →

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:

ruby
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.

ruby
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.

ruby
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.

ruby
field :birthday, as: :date, first_day_of_week: 0
ValueBehavior
0Sunday first
1Monday first
2Tuesday first
3Wednesday first
4Thursday first
5Friday first
6Saturday first
  • Type: Integer
  • Default: 1
  • Values: 0 through 6
  • 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.

ruby
field :birthday, as: :date, picker_options: {maxDate: "today"}
  • Type: Hash with 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.

ruby
field :birthday, as: :date, disable_mobile: true
ValueBehavior
falseAllows a native mobile picker when flatpickr supports it
trueUses flatpickr on mobile too
  • Type: Boolean
  • Default: false