Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在rails中使用带单选按钮的引导_Ruby On Rails_Twitter Bootstrap_Radio Button - Fatal编程技术网

Ruby on rails 在rails中使用带单选按钮的引导

Ruby on rails 在rails中使用带单选按钮的引导,ruby-on-rails,twitter-bootstrap,radio-button,Ruby On Rails,Twitter Bootstrap,Radio Button,是否可以使用引导单选按钮,即: <div class="btn-group" data-toggle="buttons-radio"> <button type="button" class="btn btn-primary">someValue</button> 一些价值 在轨道上有一个表格?有一种单选按钮方法: <%= radio_button("object", "method", "someValue") %>

是否可以使用引导单选按钮,即:

    <div class="btn-group" data-toggle="buttons-radio">
    <button type="button" class="btn btn-primary">someValue</button>

一些价值
在轨道上有一个表格?有一种单选按钮方法:

    <%= radio_button("object", "method", "someValue") %>

,但我没能设计它。我不知道是否有办法将这两个代码合并,使单选按钮具有第一个代码片段的引导外观。 谢谢 Sam

你可以这样使用

<div class="btn-group" data-toggle="buttons-radio">
  <%= f.radio_button :brand, "ABC", :id=>"first", :style=>"display:none;" %>
  <label for="first" class="btn btn-primary">First</label>

  <%= f.radio_button :brand, "PQR", :id=>"second", :style=>"display:none;" %>
  <label for="second" class="btn btn-primary">Second</label>

  <%= f.radio_button :brand, "MNO", :id=>"third", :style=>"display:none;" %>
  <label for="third" class="btn btn-primary">Third</label>
</div>

“第一个”,“样式=>”显示:无;“%>
弗斯特
“第二个”,:style=>“显示:无;”%>
第二
“第三个”,:style=>“显示:无;”%>
第三

在这里,您需要为radiobutton提供id,并可以使用标签标签中的for属性为其分配标签。以便指示相应的单选按钮

如果我错了,请纠正我,但如果将标签的value属性设置为与单选按钮参数相同,则其工作方式与为相应单选按钮分配id相同

<%= f.radio_button :brand, "MNO", :style=>"display:none;" %>
<%= f.label :brand, "Third", value => "MNO", class="btn btn-primary" %>
“显示:无;”%>
“MNO”,class=“btn btn primary”%>

需要包含正确关联单选按钮的名称,除非我遗漏了什么