- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在从我的关联复选框生成一个表。每行显示一个复选框和一些附加信息。
%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/
上面的代码将html输出为 value of b.text 是否可以修改为输出 html(即 输入标签后的标签标签)作为 value of b.text
我有一个模型 Project,它有许多 ProjectGenres 引用 Genres: class Project 虽然我不太确定我在 Controller 中做了什么?我在 params[:pr
我有一个使用 collection_check_boxes 作为输入的表单。 = f.collection_check_boxes :color_ids, group.colors, :id, :na
如何在 collection_check_boxes 上将宽度设置为百分比?由于有 7 个复选框,我希望每个复选框都占 18%。 现在的问题是,如果我将其设置为 18%,背景颜色将变为自身的 18%,
我一直在尝试将一些 CSS 类应用到 collection_check_boxes 但我无法让它工作。现在我这样做: 输出这个 HTML:
我正在使用 collection_check_boxes 并且在对齐复选框和文本时遇到问题。这是我的代码: 表单显示如下: [checkbox1] text1 [checkbox2]
GitHub 存储库:https://github.com/Yorkshireman/mywordlist 我用谷歌搜索了这个。我确定有办法,可能需要在 html 选项哈希中添加一些代码,但我无法解决
所以我使用 simple_form 来构建我的表单,但这不是必需的。 我想要做的是使用 simple_forms collection_check_boxes 并将其传递给一个数组。 我将我的标签存储
我已经设置了 2 个模型如下: class Sector { :class => 'form-vertical'} do |f| %>
我和这里的海报有同样的问题Align checkboxes for f.collection_check_boxes with Simple_Form 我的复选框代码是: 'checkbox_con
我有嵌套表单,它们试图为每个复选框插入到 Categorization 模型中。结果,我没有收到任何错误,但是 Categorization 模型的属性之一没有插入到表中。这是选中 3 个复选框中的
我正在尝试制作一个发票应用程序。创建发票的表单应包括一组复选框,以便用户可以选择要为哪些类(class)开具发票,但我收到此错误:undefined method 'collection_check_
我有以下哈希: FIELD_LIST = { -1 => 'User', -2 => 'Duration', -3 => 'Price', -4 => 'Invoiced' } 我想将
我正在使用simple_form_for仅将符号而不是模型传递到表单,以便我可以将自定义参数发送回 Controller 。我设法将复选框默认为默认所有选中状态。 我不知道如何添加全选/取消全选复选框
我正在从我的关联复选框生成一个表。每行显示一个复选框和一些附加信息。 %table = f.collection_check_boxes :task_ids, @my_collection, :id,
我试图默认选中这行 在 db t.text "committed" . 我尝试了 checked 的变体& true ,但也许我忽略了一些东西。 这是 Gist 的。 最佳答案 这里是关于如何将选中
我找到了文档 collection check boxes很难理解。参数解释为: collection_check_boxes(object, method, collection, value_me
我有一个 form_for在使用 collection_check_boxes 的 Rails 中用于作为复选框列出的部件数组的方法。我希望复选框的标签是两种方法的组合,以便每个部分的复选框都标有其名
我想将复选标记选择限制在一定数量内,这样人们就不会滥用类别选择。 这是我遇到的几个例子中的尝试。没有一个与循环一起工作。我使用常规的手动样式复选框系统对其进行了测试,并且可以正常工作。尚未找到他们使用
我在 new.html.erb 中使用 simple_form 的 collection_check_boxes。默认情况下,当 html 被渲染时,它会在最后添加隐藏字段,因为在 Controlle
我是一名优秀的程序员,十分优秀!