Search code examples
ruby-on-railsdatepickerransack

How to make Ransack search field act as datepicker?


What should I do to make my fields act as datepicker? How to add calendar icon to them? part of my view code:

 <div class="row">
          <%=  f.label 'Create At' %>
          <%= f.search_field :created_at_beginning_of_day_gteq, class: 'form-control input-sm', 'datepicker' => true %>
          <%= f.search_field :created_at_end_of_day_lt, class: 'form-control input-sm',  'datepicker' => true %>
  </div>

I'm trying to do something like this: enter image description here


Solution

  • Answering this a bit late, but I think that the following code might help.
    <%= f.date_field :business_date_gteq, class: 'form-control input-sm', 'datepicker' => true %>

    i.e. use date_field instead of search_field.
    You could add an icon as suggested by @Charan