【问题标题】:How to display one field next to other field use simple_form and bootstrap如何使用 simple_form 和 bootstrap 在另一个字段旁边显示一个字段
【发布时间】:2012-11-22 10:02:22
【问题描述】:

我的表单目前有两个字段,下拉列表和一个输入字段。这是我的表单代码:

<div class="offset3 span6">
... # other code not relevant
<div id="topic_questions">
  <%= f.simple_fields_for :topic_questions do |tq| %>
    <%= tq.link_to_remove "Remove below topic" %> <br><br>
    <%= tq.association :topic, collection: @topics, prompt: "Choose a topic", label: false %>
    <%= tq.input :number_question, label: 'Number of questions' %>
  <% end %>
  <p><%= f.link_to_add "Add a topic", :topic_questions %></p>
</div> #topic_questions
</div>

这是表单的样子:

但我希望字段输入具有标签Number of questions 将在下拉列表Choose a topic 旁边。我该怎么做?

【问题讨论】:

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


    【解决方案1】:

    我找到了解决方案,这是我的新代码:

    <div id="topic_questions">
      <%= f.simple_fields_for :topic_questions do |tq| %>
        <div class="row">
        <div class="span6"><%= tq.link_to_remove "Remove below topic" %></div><br><br>
        <div class="span3"> <%= tq.association :topic, collection: @topics, prompt: "Choose a topic", label: false %></div>
        <%= tq.input :number_question, placeholder: 'Number of questions', label: false, style: 'display: inline' %>
      <% end %>
       </div> # .row
    <p><%= f.link_to_add "Add a topic", :topic_questions %></p>
    </div>
    

    现在的表格是这样的:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-08
      • 1970-01-01
      • 1970-01-01
      • 2022-12-14
      • 2020-02-17
      • 2021-01-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多