Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

activeadmin adding datepicker

I'm working with rails' activeadmin and creating a custom form like so:

<%= semantic_form_for [:admin, Client.find(@wedding_cake.client_id), @wedding_cake] do |f| %>

than I want to add an input for a date like so:

<%= f.input :date, as: :datepicker %>

However, I'm getting "Unable to find input class for datepicker" from rails. I've tried including jquery date picker in my gem file, but that didn't change anything. What am I doing wrong?

like image 302
Silvertail Avatar asked Sep 18 '26 19:09

Silvertail


2 Answers

I ran into this exact issue and what worked for me was: https://github.com/activeadmin/activeadmin/wiki/Combine-datetime-picker-with-activeadmin#or-do-it-manually

Specifically:

In active_admin, change the column use

:as => datepicker TO :as => :string, :input_html => {:class => "hasDatetimePicker"}

However, I had to prepend the datepicker class, and in my case, change hasDatetimePicker to hasDatePicker

:as => :string, :input_html => {:class => 'datepicker hasDatePicker'}

h/t to Eugen's comment for pointing me in the right direction

like image 166
Desmond Avatar answered Sep 21 '26 11:09

Desmond


Try the DateNTimePickerActiveAdmin Rubygem. It works really well and is customisable according to your project.

You can find the documentation here: https://github.com/NikhithaGraceJosh/date_n_time_picker_activeadmin

From the docs:

Gemfile

gem 'date_n_time_picker_activeadmin'

Code Sample (In your form)

f.input :column_name, as: :datetimepicker

CSS

In active_admin.scss, add the line,

@import date_n_time_picker_activeadmin

JS

In active_admin.js, add the line,

//= require date_n_time_picker_activeadmin

Hope it's useful!

like image 44
Nikhitha Josh Avatar answered Sep 21 '26 10:09

Nikhitha Josh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!