I want to render custom form in active admin dashboard page. Code looks like:
apps/views/admin/dashboard/_form.html.erb
<%= semantic_form_for :bill, builder: ActiveAdmin::FormBuilder,action:"new" do |f| %>
<%= f.input :from_date%>
<%= f.input :to_date%>
<%= f.input :expiry_date%>
<%=f.actions :submit %>
<%end%>
app/admin/dashboard.rb
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
columns do
column do
panel "Generate Bills" do
render partial: 'form'
end
end
column do
panel "Pay Bills" do
end
end
end
end
end
I want new method of bill resource to be run on this form, because I want the active admin user to create bill objects from dashboard !
For rendering partial form in active admin
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
columns do
column do
panel "Generate Bills" do
form :partial => "form"
end
end
column do
panel "Pay Bills" do
end
end
end
end
end
app/views/admin/dashboard/_my_cool_form.html.erb
app/admin/dashboard.rb
file: Call your form as. render partial: "my_cool_form
That's it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.