2017-05-26 76 views
0

我通过网络搜索并找不到方法。到目前为止,我曾尝试:在check_box_tag中添加班级

<%= check_box_tag "course[location_ids][]", location.id, class: 'checkbox-inline'%> 

这将输出:

input type: "checkbox" name="course[location_ids][] id="course_location_ids_" value="1" checked="checked" 

出于某种原因,它使一个检查输入。

<%= check_box_tag "course[location_ids][]", location.id, :class => 'checkbox-inline'%> 

不一样的第一个

如何添加一个check_box_tag内一类

回答

2

您没有使用正确的格式

check_box_tag(name, value = "1", checked = false, options = {}) 

将标签更改为以下内容:

<%= check_box_tag "course[location_ids][]", location.id, false, class: 'checkbox-inline'%> 

注:第三选项被选中的值,你需要改变它根据你的需要

参见:check_box_tag