2012-07-13 24 views
6

我正在使用simple_form,nested_form和Twitter Bootstrap,並試圖將nested_form中的「Remove Link」與對象放在同一行。使用simple_form,nested_form和Twitter添加內聯控件在rails中使用bootstrap

現在它看起來是這樣的:

http://grab.by/eKDS

,我希望它看起來像這樣:

http://grab.by/eKEc

這裏是我的代碼如下所示:

<%= cform.simple_fields_for :licensings do |lf| %> 
    <%= lf.input :state, :collection => us_states, :wrapper => false %> 
    <%= lf.link_to_remove "Remove this Licensing", :class => 'btn btn-mini btn-danger' %> 
<% end %> 

我試過把第二個link_to_remove在第一個lf.input的塊內,但實際下拉不出現。我查看了simple_form的代碼,但是我無法追蹤是否有辦法實現這一點。

+0

怎麼樣在一個div包裹每使用CSS來處理的定位。 – diasks2 2012-07-16 09:30:40

回答

1

您是否嘗試將類「內聯」添加到嵌套窗體?

<%= form_for @test, :html => { :class => 'form-inline' } do |f| %> 
    <%= f.text_field :some_field, :class => 'text_field' %> 
    <%= f.submit "Save", :class => 'btn btn-primary' %> 
<% end %> 
+0

是的,但這是關於內聯一個特定的控件,而不是整個表單。對於我已經形式橫向的表單。 – David 2012-07-14 00:08:00

1

正如你可以在documentation看到,你可以創建自定義的包裝。您必須添加這樣的事情在你simple_form的初始化:

config.wrappers :inline do |b| 
    b.use :placeholder 
    b.use :label_input 
end 

而且使用這樣的:

<%= cform.simple_fields_for :licensings do |lf| %> 
    <%= lf.input :state, :collection => us_states, :wrapper => inline %> 
    <%= lf.link_to_remove "Remove this Licensing", :class => 'btn btn-mini btn-danger' %> 
<% end %> 
相關問題