Search code examples
ruby-on-railsruby-on-rails-3.1simple-form

simple_forms custom data attribute


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.


Solution

  • The correct API is:

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