simple_forms custom data attribute simple_forms custom data attribute ruby-on-rails ruby-on-rails

simple_forms custom data attribute


The correct API is:

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


For prosperity. On Rails 4.2.5 and Simple Form 3.2.1

The above from @rafaelfranca works for inputs:

f.input :first_name, input_html: { data: { cool_stuff: "yes" } }

If you want to add a data attribute to the simple_form_for helper:

simple_form_for @form, html: { data: { super_cool_key: "secret" } } do |f|

Note the difference: input_html: vs html:Also, the underscores will automatically get changed to a dash.