这段代码:
<%= 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。
尝试添加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' %>