From 6ce0a6de7e698dabcef10b8ebc855b47555d540b Mon Sep 17 00:00:00 2001 From: Andrey Samsonov Date: Tue, 27 Mar 2012 17:12:07 +0400 Subject: Fixing issue #2492 for master branch. ActionView::Base.field_error_proc doesn't call for label. objectify_options method should be applied to the proper options arg. See explanation and example of the bug - https://github.com/kryzhovnik/rails_field_error_proc_bug_example --- actionpack/lib/action_view/helpers/form_helper.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 6219a7a924..ab167e9fa3 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -1117,10 +1117,17 @@ module ActionView @template.fields_for(record_name, record_object, fields_options, &block) end - def label(method, text = nil, options = {}, &block) - @template.label(@object_name, method, text, objectify_options(options), &block) + 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) end + def check_box(method, options = {}, checked_value = "1", unchecked_value = "0") @template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value) end -- cgit v1.2.3 From 32763a82444ba5eb711ec0e5d6380818e5f2695d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 27 Mar 2012 19:45:51 -0300 Subject: Check if the options hash already exists and merge it with the another hash. Closes #2492 and #5615 --- actionpack/lib/action_view/helpers/form_helper.rb | 11 ++--------- actionpack/lib/action_view/helpers/tags/label.rb | 6 +++--- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index ab167e9fa3..6219a7a924 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -1117,17 +1117,10 @@ 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") @template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value) end diff --git a/actionpack/lib/action_view/helpers/tags/label.rb b/actionpack/lib/action_view/helpers/tags/label.rb index 1bd71c2778..1c8bf063ea 100644 --- a/actionpack/lib/action_view/helpers/tags/label.rb +++ b/actionpack/lib/action_view/helpers/tags/label.rb @@ -3,16 +3,16 @@ module ActionView module Tags class Label < Base #:nodoc: def initialize(object_name, method_name, template_object, content_or_options = nil, options = nil) + options ||= {} + content_is_options = content_or_options.is_a?(Hash) if content_is_options - options = content_or_options + options.merge! content_or_options @content = nil else @content = content_or_options end - options ||= {} - super(object_name, method_name, template_object, options) end -- cgit v1.2.3