19

I need to display time selector in my active admin form. I have a field start_time which is of type time. Currently I have drop-downs.

enter image description here

I need a selector similar to date picker as shown

enter image description here

For adding Date Picker I used

f.input :start_date, :as => :datepicker

ActiveAdmin.register PromoCode do

  form :html => { :enctype => "multipart/form-data" } do |f|  
    f.inputs "PromoCodes" do
    f.input :promo_code
    f.input :start_date, :as => :datepicker
    f.input :start_time
  end
  f.buttons
 end

end

Is there similar way to get time picker in active admin. Please help.

Amal Kumar S
  • 15,555
  • 19
  • 56
  • 88

2 Answers2

25

Though the datepicker will show a calendar to chose a date form, i've no idea how a time picker would work! Should it show a clock :)?

However, there is another selector in formtastic (which is used by activeadmin). that is time_picker. So you use that as follow:

f.input :start_time, :as => :time_picker

More is in the Doc

HungryCoder
  • 7,506
  • 1
  • 38
  • 51
5

there is s wiki page about using datetime picker https://github.com/activeadmin/activeadmin/wiki/Combine-datetime-picker-with-activeadmin

This is about integration of jquery timepicker plugin http://trentrichardson.com/examples/timepicker/

rubygem https://github.com/activeadmin-plugins/activeadmin_datetimepicker

Fivell
  • 11,829
  • 3
  • 61
  • 99