0

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

<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将在 dropdownlist 旁边Choose a topic。我怎样才能做到这一点?

4

1 回答 1

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>

现在的表格是这样的:

图片

于 2012-11-22T10:51:31.823 回答