Permalink
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...
1 parent 177cf4f commit 873f50a1e57a577024002ddffbeb4d25ee4bcd96 @robinst robinst committed May 22, 2011
Showing with 2 additions and 2 deletions.
  1. +1 −1 lib/formtastic/inputs/base/choices.rb
  2. +1 −1 spec/support/custom_macros.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)
@@ -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

0 comments on commit 873f50a

Please sign in to comment.