aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-08-25 11:40:59 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-08-25 11:40:59 -0300
commiteb6906890e540e751dd590a9de2016fbcb4540eb (patch)
tree397e79f6505861244f8a250f1385a272c8ff819e /actionpack
parent67274ca162cf198bc8eabd619c81e3fc6156a229 (diff)
downloadrails-eb6906890e540e751dd590a9de2016fbcb4540eb.tar.gz
rails-eb6906890e540e751dd590a9de2016fbcb4540eb.tar.bz2
rails-eb6906890e540e751dd590a9de2016fbcb4540eb.zip
Tiny refactor
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index ac2a6982fb..1ceb53fe9c 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -177,11 +177,14 @@ module ActionView
# label_tag 'name', nil, :class => 'small_label'
# # => <label for="name" class="small_label">Name</label>
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 = options.stringify_keys
+ if block_given? && content_or_options.is_a?(Hash)
+ options = content_or_options = content_or_options.stringify_keys
+ else
+ options ||= {}
+ options = options.stringify_keys
+ end
options["for"] = sanitize_to_id(name) unless name.blank? || options.has_key?("for")
- content_tag :label, content_or_options.is_a?(Hash) ? options : (content_or_options || name.to_s.humanize), options, &block
+ content_tag :label, 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