Reputation: 241
On ActiveAdmin, I have a form like this:
Note that "My thingy" is not on the DB, but calculated with the data from an API.
I want to add a filter for this field. What I'd like is to send this abc
text as a parameter to the same edit action in which I am.
My form looks like this:
form do |f|
f.inputs "Details" do
f.input :my_thingy,
label: 'My thingy',
as: :select,
collection: my_thingys,
f.input :my_thingy_filter, label: "Filter My thingy by..."
f.button :filter
end
f.actions
end
What I'd like is for this button to redirect to the same page, with the value of my_thingy_filter
as a parameter.
How can I do that?
Upvotes: 1
Views: 2788
Reputation: 241
I solved this using a member_action
:
member_action :thingy_filter, method: :patch do
redirect_to edit_thingy_path(resource, thingy_filter: params["thingy"]["thingy_filter"])
end
And formaction
with the button:
form do |f|
f.inputs "Details" do
f.input :my_thingy,
label: 'My thingy',
as: :select,
collection: my_thingys,
f.input :my_thingy_filter, label: "Filter My thingy by..."
f.button "Filter", formaction: "thingy_filter"
end
f.actions
end
Anyhow, this problem was better solved by adding a better select
Upvotes: 3