how to change class of a label for checkboxes in simple_form

前端 未结 6 864
说谎
说谎 2020-12-14 15:49

using simple_form we can change class of a label using:

label_html => {:class => \"myclass\"}

but how do we do the same when

6条回答
  •  醉梦人生
    2020-12-14 16:04

    To get the label class I had to get rid of the auto-generated label and write my own.

    this is in rails 3 with simple form 2.1 so YMMV....

    before:

    <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
    

    after:

    <%= f.label :remember_me, :class => 'remember-me' %>
    <%= f.input :remember_me, :label => false, :as => :boolean if devise_mapping.rememberable? %>
    

提交回复
热议问题