Search code examples
ruby-on-rails-4simple-form

Rails 4: tell simple_form to use input type "date" instead of showing different select boxes like Rails 4's f.date_field?


When I use Simple Form it shows three different select boxes for column type date. Instead of this I want Simple Form to show date attributes as HTML5 does. Specifically I want Simple Form to do the following:

<input type="date" name="org[established_at]" id="org_established_at">

For this I tried:

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

But this produces three different select boxes for date picking.

How do I tell Simple Form and Rails 4 to use input type "date"?


Solution

  • Recently I've done it like this:

    f.input :established_at, as: :string, input_html: { class: :datepicker }
    

    and used http://xdsoft.net/jqplugins/datetimepicker/ to show the calendar