activeadmin-plugins / active_admin_datetimepicker

:calendar: active_admin_datetimepicker gem
MIT License
73 stars 47 forks source link

Docs appear wrong for passing options #82

Closed rangerscience closed 10 months ago

rangerscience commented 1 year ago

Thank you for this code!

These do not appear to work (allow selection of past dates):

      input :start_at, as: :date_time_picker, date_time_picker_options: {
        min_date: Time.now.to_date
      }
      input :start_at, as: :date_time_picker, datepicker_options: {
        min_date: Time.now.to_date
      }

This does appear to work: (does not allow selection of past dates):

      input :start_at, as: :date_time_picker, picker_options: {
        min_date: Time.now.to_date
      }

(FYI: I found my fix my inspecting the page HTML, and noticed that the div's attribute was data-picker-options)

workgena commented 10 months ago

Checked demo applicatoin with ActiveAdmin v3.1.1 and active_admin_datetimepicker v1.1.0 and it works as described in documentation. Here is an example for an Edit product page:

# would allow only date(no time) and starting from today
f.input :available_on, as: :date_time_picker, datepicker_options: {
  timepicker: false, format: 'Y-m-d', min_date: Time.now.to_date
}
image
Click to see full example ```ruby ActiveAdmin.register Product do menu :priority => 2 permit_params :title, :description,:author,:price, :featured, :available_on, :image_file_name, :image remove_filter :image_attachment, :image_blob scope :all, :default => true form :html => { :multipart => true } do |f| f.inputs do f.semantic_errors f.input :title f.input :description f.input :author f.input :price f.input :available_on, as: :date_time_picker, datepicker_options: { timepicker: false, format: 'Y-m-d', min_date: Time.now.to_date } f.input :image_file_name f.input :image, as: :file f.actions end end index :as => :grid do |product| div do resource_selection_cell product a :href => admin_product_path(product) do static_or_uploaded_image_tag(product, [115, 115]) end end a truncate(product.title), :href => admin_product_path(product) end show :title => :title end ```