2

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?

2

2 Answers 2

8

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

Sign up to request clarification or add additional context in comments.

1 Comment

@Silvertail, accept this guys answer. I've tested it and it's correct.
1

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.