Skip to content

Commit

Permalink
Support dynamic form fields by validating the selected value of a dro…
Browse files Browse the repository at this point in the history
…pdown.

Issue [2723](thoughtbot#2723)

I want to create dynamic dropdowns in a form.
Update a field based on the selected value of another dropdown.
I achieve this by calling Model.new model_params in the controller, which is currently not supported
  • Loading branch information
y0608 committed Dec 11, 2024
1 parent 66093d0 commit 665b087
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/administrate/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def show
end

def new
resource = new_resource
if params[resource_class.model_name.element].present?
resource = new_resource(resource_params)
else
resource = new_resource
end
authorize_resource(resource)
render locals: {
page: Administrate::Page::Form.new(dashboard, resource)
Expand Down

0 comments on commit 665b087

Please sign in to comment.