simple_forms custom data attribute

Ynv picture Ynv · Nov 30, 2011 · Viewed 20.7k times · Source

I would like to have an additional data attribute on an input tag generated by simple_form. The following does not work:

<%= f.input :date, :as => 'date_picker', :data => {:datepicker => :datepicker}  %>

How could this be done? Is it possible at all? As you might have guessed: I am trying to add bootstrap-datepicker to my site without using explicit js to initialize the date picker.

Answer

rafaelfranca picture rafaelfranca · Nov 30, 2011

The correct API is:

f.input :date, :as => 'date_picker', :input_html => { :data => {:datepicker => :datepicker} }