我是活跃管理员并使用以下表单
的新手active_admin_form_for resource, :url => account_setup_admin_customer_path(resource), :method => :post, :html => {:class => "new_meeting_search", :id => "meeting_search"} do |f|
f.inputs "Customer Details" do
h2 "Customer Name: #{resource.first_name} #{resource.last_name}"
h2 "Company: #{resource.company_name}"
h2 "Email: #{resource.email}"
f.input :bill_to
f.input :ship_to
f.input :primary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]]
f.input :secondary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]]
f.input :ips_primary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]]
f.input :ips_secondary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]]
f.input :ipi_account_number
f.input :ipage_username
f.input :ipage_password
f.input :status, :as => :select, :collection => [["Approved", "Approved"], ["Denied", "Denied"]]
f.input :status_comment
end
f.actions
end
我需要单独的操作按钮“Approve”,“Deny”,“Cancel”,而不是状态下拉列表。我不确定如何以活动形式添加自定义按钮。
答案 0 :(得分:0)
你可以放3个链接进行模拟。更多详细信息,您可以参考AA的表单自定义document。
答案 1 :(得分:0)
为此,您需要使用member_action
。
首先,在您的模型中创建一个公共方法:
model MyModel
#...
def approve
#... any logic here, for example:
update(status: 'Approved')
end
end
然后,在AA页面中你会做:
action_item only: [:edit] do # or any page, where you need this button
link_to('Approve', the_path_to_aprove(resource), method: :post
end
member_action :approve, method: :post do
if resource.approve
redirect_to somewhere_path, notice: "This have been approved!"
else
redirect_to somewhere_else_path, alert: "Sorry, not all requirements were met for approving"
end
end
end