这段代码:
<%= f.input :exploratory, as: :radio_buttons,
collection: [['Exploratory', true], ['Preparatory', false]],
label: false %>产生以下结果:

这几乎就是我想要的--唯一的问题是单选按钮上方的“探索”标签。
有没有办法让simple_form省略单选按钮集的标签,而只显示单个按钮标签?或者,如果不可能,是否有方法可以将标签设置为不同的值。
我在Rails 5.2.3和Bootstrap 4.3.1中使用Simple Form 4.1.0。
发布于 2019-04-18 13:49:33
尝试添加label: false
<%= f.input :exploratory, as: :radio_buttons,
collection: [['Exploratory', true], ['Preparatory', false]],
label: false %>这将生成不带标签的HTML
测试的

此外,还可以通过添加label: 'Changed label'来更改标签
<%= f.input :exploratory, as: :radio_buttons,
collection: [['Exploratory', true], ['Preparatory', false]],
label: 'Changed Label' %>

发布于 2021-01-28 17:21:05
这是simple_form_bootstrap包装器的一个问题,对于集合输入,您必须指定legend_tag: false而不是label: false。
https://stackoverflow.com/questions/55739750
复制相似问题