由于一些技术原因,我不得不将ActiveAdmin编辑表单从我使用的更改为ERB部分。
表单相当庞大,我不得不将其拆分为选项卡。尝试使用ERB partial中的<% tabs do %>
添加标签时,rails server
输出中会显示以下错误:
Completed 500 Internal Server Error in 209ms
ActionView::Template::Error (undefined method `tabs' for #<#<Class:0x007fb1827cdbf8>:0x007fb181b16d60>):
1: <%= semantic_form_for [:admin, @consignment], builder: ActiveAdmin::FormBuilder, html: { enctype: 'multipart/form-data' } do |f| %>
2: <% f.semantic_errors *f.object.errors.keys %>
3:
4: <% tabs do %>
5:
6: <% tab 'Foo' do %>
7:
app/views/admin/consignments/_form.erb:4:in `block in _app_views_admin_consignments__form_erb__783297827544755550_70200180247600'
app/views/admin/consignments/_form.erb:1:in `_app_views_admin_consignments__form_erb__783297827544755550_70200180247600'
据我所知,我可能必须在某处包含一个帮助程序才能显示标签,但我不确定要使用哪一个以及在哪里包含它。
答案 0 :(得分:3)
我最终以下列方式手动输入HTML:
<div class="tabs">
<ul class="nav nav-tabs" role="tablist">
<li><a href="#consignment-details">Consignment Details</a></li>
<li><a href="#consignment-details">Trucks</a></li>
</ul>
<div class="tab-content">
<div id="consignment-details">
</div>
<div id="containers">
</div>
</div>
</div>
答案 1 :(得分:2)
使用form do |f|; end
块
div(class: 'tabs') do
ul(class: 'nav nav-tabs', role: 'tablist') do
li { link_to 'Consignment Details', '#consignment-details' }
li { link_to 'Containers', '#containers' }
end
div(class: 'tab-content') do
div(id: 'consignment-details') do
f.inputs do #your form goes here
#...
end
end
#second tab
end
end