我的表单目前有两个字段,下拉列表和输入字段。这是我的表格代码:
<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>
这就是表单的样子:
image http://s7.postimage.org/mprqpg2e3/step2_form.png
但我希望字段输入标签Number of questions
将在dropdownlist Choose a topic
旁边。我怎么能这样做?
答案 0 :(得分: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>
表单现在看起来像这样: