Skip to content
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

Ensure radio/checkbox DOM IDs with float values are unique #34975

Merged
merged 1 commit into from
Feb 5, 2019

Conversation

markedmondson
Copy link
Contributor

@markedmondson markedmondson commented Jan 18, 2019

Summary

Updates the DOM ID sanitizer for form input values so as to not cause potential duplicate values when using float values on a collection.

For example:

collection_check_boxes :user, :name, [1.0, 10], :to_s, :to_s

Returns:

<input type="hidden" name="user[name][]" value="" />
<input type="checkbox" value="1.0" name="user[name][]" id="user_name_10" />
<label for="user_name_10">1.0</label>
<input type="checkbox" value="10" name="user[name][]" id="user_name_10" />
<label for="user_name_10">10</label>

With this change:

<input type="hidden" name="user[name][]" value="" />
<input type="checkbox" value="1.0" name="user[name][]" id="user_name_1_0" />
<label for="user_name_1_0">1.0</label>
<input type="checkbox" value="10" name="user[name][]" id="user_name_10" />
<label for="user_name_10">10</label>

Fixes #34974

@rails-bot rails-bot bot added the actionview label Jan 18, 2019
Copy link
Member

@rafaelfranca rafaelfranca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a changelog entry and squash your commits?

@markedmondson markedmondson force-pushed the float_dom_ids branch 3 times, most recently from d4e6770 to 49bfbcb Compare January 19, 2019 00:01
@markedmondson
Copy link
Contributor Author

Done and done!

@gmcgibbon gmcgibbon merged commit f8696b8 into rails:master Feb 5, 2019
gmcgibbon added a commit that referenced this pull request Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants