Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix destructive stringify_keys for label_tag

  • Loading branch information...
commit 895d64531d25a76c1de2d4fec9aba68c0ee8c104 1 parent 54b8356
@waynn waynn authored
View
4 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -179,9 +179,9 @@ def text_field_tag(name, value = nil, options = {})
def label_tag(name = nil, content_or_options = nil, options = nil, &block)
options = content_or_options if block_given? && content_or_options.is_a?(Hash)
options ||= {}
- options.stringify_keys!
+ options = options.stringify_keys
options["for"] = sanitize_to_id(name) unless name.blank? || options.has_key?("for")
- content_tag :label, content_or_options || name.to_s.humanize, options, &block
+ content_tag :label, content_or_options.is_a?(Hash) ? options : (content_or_options || name.to_s.humanize), options, &block
end
# Creates a hidden form input field used to transmit data that would be lost due to HTTP's statelessness or
View
6 actionpack/test/template/form_tag_helper_test.rb
@@ -530,6 +530,12 @@ def test_image_submit_tag_options_symbolize_keys_side_effects
assert_equal options, { :option => "random_option" }
end
+ def test_image_label_tag_options_symbolize_keys_side_effects
+ options = { :option => "random_option" }
+ actual = label_tag "submit source", "title", options
+ assert_equal options, { :option => "random_option" }
+ end
+
def protect_against_forgery?
false
end
Please sign in to comment.
Something went wrong with that request. Please try again.