-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple inputs with the same name generate unparseable names in Rails >= 7.1.1 #1834
Comments
sobakasu
added a commit
to katalyst/koi
that referenced
this issue
Mar 7, 2024
related to heartcombo/simple_form#1834 The previous html for editing a setting looked like this: <input class="string optional form--medium enhanced" type="text" name="setting[setting[36086]][value]" id="setting_setting_70243__value"> it now looks like: <input value="Job position" class="string required form--medium enhanced" type="text" name="setting[setting_36086][value]" id="setting_setting_36086_value">
sobakasu
added a commit
to katalyst/koi
that referenced
this issue
Mar 7, 2024
related to heartcombo/simple_form#1834 The previous html for editing a setting looked like this: <input class="string optional form--medium enhanced" type="text" name="setting[setting[36086]][value]" id="setting_setting_70243__value"> it now looks like: <input value="Job position" class="string required form--medium enhanced" type="text" name="setting[setting_36086][value]" id="setting_setting_36086_value">
sobakasu
added a commit
to katalyst/koi
that referenced
this issue
Mar 7, 2024
related to heartcombo/simple_form#1834 The previous html for editing a setting looked like this: <input class="string optional form--medium enhanced" type="text" name="setting[setting[36086]][value]" id="setting_setting_70243__value"> it now looks like: <input value="Job position" class="string required form--medium enhanced" type="text" name="setting[setting_36086][value]" id="setting_setting_36086_value">
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Hey, there.
Rack changed how they parse query parameters which causes the usage of multiple inputs of the same name to generate unparseable query parameters.
Here is a quick example:
The use case here is to create parameters that contain an array in bar which consists of hashes containing id keys.
Current behavior
This produces inputs with names like this:
foo[bar[][id]]
which is no longer supported by rack see rack/rack#2128The resulting parameters look like this:
"foo"=>{"bar["=>{"id"=>{"]"=>"33"}}}
Maybe this is not the intended way to create query params that contain an array containing hashes?
I tried using
simple_fields_for
but I could not make it workExpected behavior
I think the names generated by a form like this should follow the conventions mentioned by rails: https://guides.rubyonrails.org/form_helpers.html#understanding-parameter-naming-conventions
thus generating names like this:
foo[bar][][id]
Current Workaround
Simply setting the name manually by adding
input_html: { name: '...' }
BTW:
If anyone could point out where this is implemented I am happy to create a PR but I currently don't have the time to dig this myself.
The text was updated successfully, but these errors were encountered: