我在activeadmin页面中遇到了无资源表单的问题:
ActiveAdmin.register_page 'TestDashboard' do
menu :label => 'TestDashboard'
content title: 'TestDashboard' do
columns do
column do
div do
semantic_form_for 'dashboard', :url => '#' do |f|
f.inputs :name => 'Configure', :class => 'inputs' do
f.input :target
f.input :name
end
end
end
end
end
end # content
end
仅显示最后一个字段(名称)。生成的html是:
<form novalidate="novalidate" method="post" class="formtastic dashboard" action="#" accept-charset="UTF-8">
<div style="margin:0;padding:0;display:inline"><input type="hidden" value="✓" name="utf8">
<input type="hidden" value="3424234blabla" name="authenticity_token">
</div>
<fieldset class="inputs">
<legend>
<span>Configure</span>
</legend>
<ol>
<li id="dashboard_name_input" class="string input required stringish">
<label for="dashboard_name" class="label">Name<abbr title="required">*</abbr></label>
<input type="text" name="dashboard[name]" id="dashboard_name">
</li>
</ol>
</fieldset>
</form>
提前谢谢。
答案 0 :(得分:4)
你应该把它放在一个部分:
在views / admin / testdashboard / _configure_form.html.erb
中<%= semantic_form_for 'dashboard', :url => '#' do |f| %>
<%= f.inputs :name => 'Configure', :class => 'inputs' do %>
<%= f.input :target %>
<%= f.input :name %>
<% end %>
<% end %>
在TestDashboard.rb
中ActiveAdmin.register_page 'TestDashboard' do
menu :label => 'TestDashboard'
content title: 'TestDashboard' do
columns do
column do
render "configure_form"
end
end
end # content
end
然后应该很好地工作:)
答案 1 :(得分:0)
I have the same problem, and i use active_admin_form_for
instead semantic_form_for
Example:
ActiveAdmin.register_page 'TestDashboard' do
menu :label => 'TestDashboard'
content title: 'TestDashboard' do
columns do
column do
div do
active_admin_form_for'dashboard', :url => '#' do |f|
f.inputs :name => 'Configure', :class => 'inputs' do
f.input :target
f.input :name
end
end
end
end
end
end # content
end