In a project that already using Activeadmin I had the requeriment of modify the actual
form to create a student, but without validating that, so the solution was create into
the model of active admin form
and declare the form with two actions, one with
the clasical behaviour and other when passed the params[:managed]
with a custom route
ActiveAdmin.register InvestmentItem do
# ..
form do |f|
f.inputs do
f.input :student, as: :select, collection: User.students
f.input :amount
unless params[:managed]
f.input :course, as: :select, collection: Course.all
f.input :created_at
end
end
if params[:managed]
f.action :submit, as: :input, button_html: { formaction: :managed_create }
else
f.actions # this go to create/update
end
end
# ...
controller do
def managed_create
# do whatewer you want
end
end
end
Then button_html: { formaction: :managed_create }
options in a :submit
, does the trick.