简体   繁体   中英

Rails 6 ActiveAdmin dynamic dropdown selection with page reload

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.

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM