更新:我在做了一些挖掘並意識到這可能是導致問題的twitter-bootstrap後更新了此內容。使用simple_form,nested_form和twitter-bootstrap嵌套表格格式
這裏是我的嵌套形式的粗略版本:
<%= simple_nested_form_for @user, :html => { :class => 'form-horizontal' } do |f| %>
<fieldset>
<%= f.input :email %>
<%= f.input :name_first %>
<%= f.input :name_last %>
<table class="table table-striped">
<thead>
<tr>
<th>Active</th>
<th>Company</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<%= f.simple_fields_for :roles, :wrapper_tag => :tr do |role_form| %>
<td><%= role_form.hidden_field :id %><%= role_form.input :active, :label => false, :wrapper => false %></td>
<td><%= role_form.association :company, :label => false, :wrapper => false %></td>
<td><%= role_form.input :role, :label => false, :collection => [ "Guest", "User", "Inspector", "Owner"], :wrapper => false %></td>
<td><%= role_form.link_to_remove "Delete", :class => 'btn btn-mini btn-danger' %>
</td>
<% end %>
</tbody>
</table>
<p><%= f.link_to_add "Add a Role", :roles %></p>
</div>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to 'Cancel', users_path, :class => 'btn' %>
</div>
</fieldset>
<% end %>
當它呈現表中的行中的字段縮進一樣通過{ :class => 'form-horizontal' }
父窗體。我只是想要沒有包裝divs等字段,似乎無法弄清楚。我認爲:wrapper => false
是票,但迄今爲止沒有運氣。
丹
你可以發佈你的完整的最終解決方案,因爲我得到的問題將nested_form部分添加到表中,它看起來你正在工作。我會感激。 – 2012-10-16 22:30:20
我最終離開了這個觀點 - 如果我記得圍繞輸入的div是最終的解決方案。 – 2012-10-20 06:30:52