【问题标题】:Inline Radio Buttons using simple form and twitter bootstrap使用简单表单和 twitter 引导的内联单选按钮
【发布时间】:2013-06-28 23:23:45
【问题描述】:

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

O Apple O Microsoft O Twitter O Square

目前我有这条线:

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

但我的表格是这样的:

苹果
微软
O 推特
O广场

我已经在该输入周围尝试了&lt;div class="form-inline"&gt;&lt;/div&gt; 并添加了

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

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

【问题讨论】:

标签: ruby-on-rails forms twitter-bootstrap simple-form


【解决方案1】:

你可以用普通的导轨来做

 <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>

【讨论】:

    【解决方案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>
    

    【讨论】:

    • 试试这个
    • 感谢您的回答,但我尝试使用 simple_form 来完成
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 2014-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多