You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What would you like to be able to do? Can you provide some examples?
Create a new resource using params.
The new method doesn't support params. I want to be able to do: Model.new params. This is because I am trying to make dynamic select fields - like so: https://youtu.be/vKjWXMHzOoA?list=LL&t=884
How could we go about implementing that?
This can be easily achieved by using new_resource(resource_params) and adding a simple check if there are any parameters specified. If not - proceed with default behaviour.
# application_controller.rb
def new
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)
}
end
The text was updated successfully, but these errors were encountered:
y0608
added a commit
to y0608/administrate
that referenced
this issue
Dec 11, 2024
…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
What would you like to be able to do? Can you provide some examples?
Create a new resource using params.
The new method doesn't support params. I want to be able to do:
Model.new params
. This is because I am trying to make dynamic select fields - like so: https://youtu.be/vKjWXMHzOoA?list=LL&t=884How could we go about implementing that?
This can be easily achieved by using
new_resource(resource_params)
and adding a simple check if there are any parameters specified. If not - proceed with default behaviour.The text was updated successfully, but these errors were encountered: