Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't strip '-' in choice_html_safe_value

When using a radio with a collection of e.g. [1, 0, -1], the ids of the
generated input tags are the same for 1 and -1. By not stripping '-', we
get unique ids in this case.
  • Loading branch information...
commit 873f50a1e57a577024002ddffbeb4d25ee4bcd96 1 parent 177cf4f
@robinst robinst authored
View
2  lib/formtastic/inputs/base/choices.rb
@@ -64,7 +64,7 @@ def custom_choice_html_options(choice)
end
def choice_html_safe_value(choice)
- choice_value(choice).to_s.gsub(/\s/, '_').gsub(/\W/, '').downcase
+ choice_value(choice).to_s.gsub(/\s/, '_').gsub(/[^\w-]/, '').downcase
end
def choice_input_dom_id(choice)
View
2  spec/support/custom_macros.rb
@@ -296,7 +296,7 @@ def it_should_use_the_collection_when_provided(as, countable)
output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_general']")
output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_design']")
output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_development']")
- output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_quasiserious_inventions']")
+ output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_category_name_quasi-serious_inventions']")
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.