Easepick

Enhanced date picker field with powerful calendar functionality using the Easepick library.

Usage

<%= form_with url: root_path do |f| %>
  <%= f.easepick :birthday %>
  <%= f.easepick :appointment, data: { easepick_plugins: ["LockPlugin"] } %>
<% end %>
Props
PropTypeDefaultDescription
sizeSymbol
:sm | :md | :lg
:mdSize of the date picker field.
labelString | falsehumanized attribute nameCustom label text. Set to `false` to hide the label.
hintStringnilHelper text displayed below the field.
errorStringnilManual error message. ActiveRecord errors are displayed automatically.
disabledBooleanfalseDisable the field.
data-easepick_pluginsArray[]Easepick plugins to enable (e.g., LockPlugin, AmpPlugin).
data-easepick_lock_min_dateDatenilMinimum selectable date (requires LockPlugin).
data-easepick_amp_dropdownHashnilAmpPlugin dropdown configuration (months, years, minYear, maxYear).

Also accepts any HTML attributes via **options (e.g., id:, data:, aria:). class: is also supported for custom styling.

Examples

Basic Date Picker

<%= form_with url: root_path do |f| %>
  <%= f.easepick :birthday %>
<% end %>

Easepick sizes

<%= form_with url: root_path do |f| %>
  <%= f.easepick :large_field, size: :lg %>
  <%= f.easepick :default_field %>
  <%= f.easepick :small_field, size: :sm %>
<% end %>

Label customization

<%= form_with url: root_path do |f| %>
  <%= f.easepick :custom_label, label: "Custom Label Text" %>
  <%= f.easepick :no_label, label: false %>
<% end %>

Hint message

Select your birth date

<%= form_with url: root_path do |f| %>
  <%= f.easepick :birthday_with_hint, hint: "Select your birth date" %>
<% end %>

Date Picker with Plugins

Future dates only

Select appointment date

<%= form_with url: root_path do |f| %>
  <%= f.easepick :future_date, data: {
    easepick_plugins: ["LockPlugin"],
    easepick_lock_min_date: Date.current
  }, hint: "Future dates only" %>

  <%= f.easepick :appointment, data: {
    easepick_plugins: ["LockPlugin", "AmpPlugin"],
    easepick_amp_dropdown: {
      months: true,
      years: true,
      maxYear: Time.zone.today.year + 2,
      minYear: Time.zone.today.year
    }
  }, hint: "Select appointment date", required: true %>
<% end %>

Disabled State

<%= form_with url: root_path do |f| %>
  <%= f.easepick :disabled_field, value: Date.current, disabled: true %>
<% end %>

Validation

Is required

This field has a custom error

<% user = User.new %>
<% user.errors.add(:last_name, "is required") %>
<%= form_with model: user, url: root_path do |f| %>
  <%= f.easepick :last_name, label: "Birthday" %>
<% end %>

<%= form_with url: root_path do |f| %>
  <%= f.easepick :with_custom_error, error: "This field has a custom error" %>
<% end %>