simple_forms custom data attribute

痞子三分冷 提交于 2019-12-03 01:03:43
rafaelfranca

The correct syntax 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!