Rails 6 ActiveAdmin dynamic dropdown selection with page reload

690 Views Asked by At

I have a following ActiveAdmin form

  form do |f|
    f.inputs do
      f.input :dropdown_a, # Dropdown menu
      f.input :dropdown_b, # Dropdown menu
      f.input :quantity
      f.input :remarks
    end
  end

I want to dynamically select options of dropdown_b depending on value of dropdown_a. How can I achieve this? It doesn't have to be javascript. I am fine with reloading page with selected values onchange.

1

There are 1 best solutions below

0
Isabela Porto On

I guess you could extract something from this question: Rails - pass a parameter to controller from form select dropdown

Using as collection for the second dropdown a variable, nil at the start, and once the user change the first dropdown an ajax request is made and the variable receive the new value from params.