From 33c4b07028b9f2023b8a53b76b933c30d4be534f Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Sat, 8 Aug 2009 00:29:58 +0300 Subject: [PATCH] [PATCH] Rendering consistency bug for label_tag with radio_button_tag --- .../lib/action_view/helpers/form_tag_helper.rb | 3 ++- actionpack/test/template/form_tag_helper_test.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index e126b35..b608240 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -131,7 +131,8 @@ module ActionView # label_tag 'name', nil, :class => 'small_label' # # => def label_tag(name, text = nil, options = {}) - content_tag :label, text || name.to_s.humanize, { "for" => sanitize_to_id(name) }.update(options.stringify_keys) + pretty_name = name.is_a?(Symbol) ? name : name.gsub(/(?!-)\W/, "").downcase + content_tag :label, text || name.to_s.humanize, { "for" => sanitize_to_id(pretty_name) }.update(options.stringify_keys) end # Creates a hidden form input field used to transmit data that would be lost due to HTTP's statelessness or diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 7900426..cd057cd 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -252,6 +252,12 @@ class FormTagHelperTest < ActionView::TestCase label_elem = root_elem(label_tag("item[title]")) assert_match VALID_HTML_ID, label_elem['for'] end + + def test_label_tag_with_dotted_text + actual = label_tag "apache2.2", "Apache 2.2" + expected = %() + assert_dom_equal expected, actual + end def test_boolean_options assert_dom_equal %(), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") -- 1.6.2.2