Rod*_*igo 13 ruby ruby-on-rails activeadmin
我试图在我的activeAdmin表单方法中使用render方法,但在代码中插入render后,它停止工作.
form do |f|
f.inputs I18n.t('sale_header') do
f.input :client
f.input :room
end
f.inputs I18n.t('sale_items') do
render :partial => "form_sale"
end
f.inputs I18n.t('totalization') do
f.input :sub_total, :input_html => { :disabled => :true }
f.input :discount
f.input :total_value, :input_html => { :disabled => :true }
end
f.buttons
end
Run Code Online (Sandbox Code Playgroud)
插入render方法后,屏幕上只显示form_sale内容.
有帮助吗?谢谢!
根据文档,在active_admin中自定义表单的正确方法是:
ActiveAdmin.register Post do
form :partial => "form"
end
Run Code Online (Sandbox Code Playgroud)
然后在你的部分"_form.html.erb"中你应该使用formtastic DSL,如下所示:
<%= semantic_form_for [:admin, @post] do |f| %>
<%= f.inputs :title, :body %>
<%= f.buttons :commit %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
在网页上明确说明:
If you require a more custom form than can be provided through the DSL, you can pass
a partial in to render the form yourself.
Run Code Online (Sandbox Code Playgroud)
这意味着,active_admin的DSL有一些轻微的限制.
我用'render'和'form:partial'完成的所有实验都没有结果.如果您想使用partial,它应该替换所有表单.
归档时间: |
|
查看次数: |
2447 次 |
最近记录: |