gpt4 book ai didi

ruby-on-rails - 从 collection_check_boxes 中移除外部标签

转载 作者:行者123 更新时间:2023-12-02 01:24:25 24 4
gpt4 key购买 nike

我正在从我的关联复选框生成一个表。每行显示一个复选框和一些附加信息。

%table
= f.collection_check_boxes :task_ids, @my_collection, :id, :label do |r|
%tr
%td= r.label
%td= r.check_box
%td= r.object.due_date

但这会破坏我的 HTML,因为输出如下所示:

<table>
<span><label for="task_ids_1"> <--- I want to remove this...
<tr>
<td><label for="task_ids_1">My Name</label></td>
<td><input type="checkbox" value="8" name="user[task_ids][]" id="task_ids_1" /></td>
<td>I'm in.</td>
</tr>
</label></span> <--- ...and this!
</table>

当然我试过设置label: false,但是这个选项没有效果。我怎样才能去掉外面的标签?

最佳答案

差不多一年后,我终于自己弄明白了。有一个名为 boolean_style::inline 的选项使它起作用。

%table
= f.collection_check_boxes :task_ids, @coll, :id, :label, boolean_style: :inline do |r|
%tr
%td= r.label
%td= r.check_box
%td= r.object.due_date

我在这里找到了解决方案和解释https://github.com/plataformatec/simple_form/issues/1266 :

Since you want it to be inline (because you're making it nested by yourself) you need to use boolean_style: :inline config.

关于ruby-on-rails - 从 collection_check_boxes 中移除外部标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37975486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com