内联表单Twitter Bootstrap +简单表单+ Rails

时间:2013-06-02 10:01:28

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

正如标题所示,我正在使用Bootstrap和Simple_Form。我想要:thumbnail_layout_horizontal& :thumbnail_layout_vertical在同一条线上,但似乎无法弄明白?

<%= simple_form_for(@shop, :html => {:class => "form-horizontal" }) do |f| %>
  <%= f.error_notification %>

  <%= f.input :store, :as => :hidden %>
  <%= f.input :product_id, :as => :hidden %>

  <%= f.input :has, :wrapper => :prepend, :label => 'Has' do %>
    <%= content_tag :span, "#", :class => "add-on" %>
    <%= f.input_field :has %>
  <% end %>

  <%= f.input :published, :as => :boolean %>
  <%= f.input :thumbnail_layout_horizontal, input_html: { class: 'span1' }, :collection => ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], :label => false %>
  <%= f.input :thumbnail_layout_vertical, input_html: { class: 'span1' }, :collection => ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], :label => false %>

  <%= f.button :submit %>
<% end %>

1 个答案:

答案 0 :(得分:0)

您需要将它们包装在名为controls-row

的div中

根据bootstrap网站上的示例http://twitter.github.io/bootstrap/base-css.html#forms

如: -

<div class="controls controls-row">
    <%= f.input :thumbnail_layout_horizontal, input_html: { class: 'span1' }, :collection => ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], :label => false %>
    <%= f.input :thumbnail_layout_vertical, input_html: { class: 'span1' }, :collection => ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], :label => false %>
</div>

我认为你希望你的跨度有不同的值,即不是两个span1