如何更改simple_form中复选框的标签类别 [英] how to change class of a label for checkboxes in simple_form
本文介绍了如何更改simple_form中复选框的标签类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 simple_form
我们可以使用以下方法更改标签的类别:
using simple_form
we can change class of a label using:
label_html =>{:class =>我的课堂"}
但是在处理复选框时我们如何做同样的事情?
but how do we do the same when dealing with checkboxes?
simple_form
指定collection_check_boxes
的默认类
有没有办法改变这个默认类?
Is there a way to change this default class?
推荐答案
我想更新这个答案,以防有人像我一样来这里寻找方法.
I wanted to give an update to this answer in case someone comes here looking for a way to do this as I did.
您可以使用此选项为标签指定一个类别 :item_wrapper_class =>'class_goes_here'
You can give the label a class with this option :item_wrapper_class => 'class_goes_here'
这是一个完整的例子:
= user.input :resident,
:collection => [["In the U.S", true],["Outside the U.S.", false]],
:label_method => :first,
:value_method => :last,
:as => :radio_buttons,
:label => "Where is your principle residence?",
:item_wrapper_class => 'inline'
这篇关于如何更改simple_form中复选框的标签类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文