diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-03-27 20:01:59 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-03-27 20:01:59 -0300 |
commit | 6968bc16a1a609c56cf056cd9cd8f8de251defde (patch) | |
tree | 6653b5174fe6e925d082f0f19ca9b21ce2a8e56e /actionpack/lib | |
parent | 7111133371c08d2096cbcffa661860c9ea2c5813 (diff) | |
download | rails-6968bc16a1a609c56cf056cd9cd8f8de251defde.tar.gz rails-6968bc16a1a609c56cf056cd9cd8f8de251defde.tar.bz2 rails-6968bc16a1a609c56cf056cd9cd8f8de251defde.zip |
Check if the options hash already exists and merge it with the another
hash.
Closes #2492 and #5614
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index ce8187e870..035123b5fc 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -656,15 +656,16 @@ module ActionView # 'Accept <a href="/terms">Terms</a>.'.html_safe # end def label(object_name, method, content_or_options = nil, options = nil, &block) + options ||= {} + content_is_options = content_or_options.is_a?(Hash) if content_is_options || block_given? - options = content_or_options if content_is_options + options.merge!(content_or_options) if content_is_options text = nil else text = content_or_options end - options ||= {} InstanceTag.new(object_name, method, self, options.delete(:object)).to_label_tag(text, options, &block) end @@ -1310,14 +1311,8 @@ module ActionView @template.fields_for(record_name, record_object, fields_options, &block) end - def label(method, content_or_options = nil, options = {}, &block) - if content_or_options.is_a?(Hash) - content_or_options = objectify_options(content_or_options) - else - options = objectify_options(options) - end - - @template.label(@object_name, method, content_or_options, options, &block) + def label(method, text = nil, options = {}, &block) + @template.label(@object_name, method, text, objectify_options(options), &block) end def check_box(method, options = {}, checked_value = "1", unchecked_value = "0") |