我是否可以在集合中的每个单选按钮之间出现行间隔?
f.collection_radio_buttons(
:chosen,
[['A1', 1],['A2', 2], ['A3', 3]],
:last,
:first,
html_options: { class: 'form-control' }
)发布于 2016-03-26 18:42:20
我无法测试,但我认为这可以帮助:
<%= f.collection_radio_buttons(:chosen, [['A1', 1],['A2', 2], ['A3', 3]], :last, :first, html_options: { class: 'form-control' }) do |b| %>
<%= b.label { b.radio_button + " " + b.text } %><br>
<% end %>发布于 2016-03-26 18:56:45
看起来form_tag版本允许通过块进行定制,所以我假设form_for也是如此。
buttons
还可以通过给方法块来定制元素的显示方式: collection_radio_buttons(:post、:author_id、Author.all、:id、:name_with_initial)
所以你可以试试这样的方法
<%= f.collection_radio_buttons(:chosen, [['A1', 1],['A2', 2], ['A3', 3]], :last, :first, html_options: { class: 'form-control' }) do |b| %>
<%= b.label { b.radio_button } %><br>
<% end %>发布于 2018-06-19 22:42:46
我就是这样做到的:
= residency.collection_radio_buttons :own,
[[true, 'I Own This Home'], [nil, 'I Rent'], [false, 'I Live Rent Free']],
:first,
:last,
item_wrapper_tag: :div, <-- MAGIC IS HERE
label: false do |rdb|
.d-block
= rdb.radio_button + rdb.label(class: 'p-l-1')https://stackoverflow.com/questions/36239107
复制相似问题