Amal Kumar S
Amal Kumar S

Reputation: 16055

How to add time picker in Active Admin + Rails 3

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.

Upvotes: 19

Views: 16739

Answers (2)

Fivell
Fivell

Reputation: 11929

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

Upvotes: 5

HungryCoder
HungryCoder

Reputation: 7616

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

Upvotes: 25

Related Questions