Dan*_*pin 6 nested-forms ruby-on-rails-3 simple-form twitter-bootstrap
更新: 我在做了一些挖掘并意识到这可能是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 %>
Run Code Online (Sandbox Code Playgroud)
当它被渲染时,表行中的字段通过缩进与父表单相同{ :class => 'form-horizontal' }.我只是想要没有包装div等的字段,似乎无法弄明白.我以为这:wrapper => false是票,但到目前为止没有运气.
担
我最终自己弄清楚了。您必须将表单样式(表单水平)移动到非嵌套字段周围的 div 中:
<%= simple_nested_form_for @user do |f| %>
<fieldset>
<div class="form-horizontal">
<%= f.input :email %>
<%= f.input :name_first %>
<%= f.input :name_last %>
<%= f.input :phone %>
<%= f.input :mobile %>
<%= f.input :password %>
<%= f.input :password_confirmation %>
</div>
<div class="tubbable">...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5637 次 |
| 最近记录: |