0

我正在尝试创建一个显示单选选项的表单,如下所示:

O 苹果 O 微软 O Twitter O Square

目前我有这条线:

<%= f.association :company, as: :radio, label: false %>

但我的表格是这样的:

O 苹果
O 微软
O Twitter
O Square

我已经尝试过<div class="form-inline"></div>该输入并添加

<%= f.association :company, as: :radio, label: false, :item_wrapper_class => 'inline' %>

我需要将输入更改为集合吗?

4

2 回答 2

0

with regular rails you can do

 <div class="radio">
    <label>
      <%= radio_button_tag "Product Type", "Retail Product or Service", true %>
      Retail Product or Service
    </label>
    <label>
      <%= radio_button_tag "Product Type", "Tax Code", false %>
      Tax Code
    </label>
    <label>
      <%= radio_button_tag "Product Type", "Discount Amount", false %>
      Discount Amount
    </label>
    <label>
      <%= radio_button_tag "Product Type", "Discount Percent", false %>
      Discount Percent
    </label>
  </div>
于 2015-01-14T18:55:42.557 回答
-2

你可以使用这个:

<label class="checkbox inline">
  <input type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
<label class="checkbox inline">
  <input type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
<label class="checkbox inline">
  <input type="checkbox" id="inlineCheckbox3" value="option3"> 3
</label>

或者这个(仅限标签形式):

<form class="form-inline">
  <input type="text" class="input-small" placeholder="Email">
  <input type="password" class="input-small" placeholder="Password">
  <label class="checkbox">
    <input type="checkbox"> Remember me
  </label>
  <button type="submit" class="btn">Sign in</button>
</form>
于 2013-06-28T23:31:52.970 回答