From 81b14b7c5c32ef1b21227f7f2548685801930201 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 21 Aug 2014 22:07:33 -0700 Subject: Revert "Add I18n support for `:placeholder` HTML option is passed to form fields" --- .../action_view/helpers/tags/placeholderable.rb | 32 ---------------------- 1 file changed, 32 deletions(-) delete mode 100644 actionview/lib/action_view/helpers/tags/placeholderable.rb (limited to 'actionview/lib/action_view/helpers/tags/placeholderable.rb') diff --git a/actionview/lib/action_view/helpers/tags/placeholderable.rb b/actionview/lib/action_view/helpers/tags/placeholderable.rb deleted file mode 100644 index 313aa725c9..0000000000 --- a/actionview/lib/action_view/helpers/tags/placeholderable.rb +++ /dev/null @@ -1,32 +0,0 @@ -module ActionView - module Helpers - module Tags # :nodoc: - module Placeholderable # :nodoc: - def initialize(*) - super - - if tag_value = @options[:placeholder] - object_name = @object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1') - method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}" - - if object.respond_to?(:to_model) - key = object.class.model_name.i18n_key - i18n_default = ["#{key}.#{method_and_value}".to_sym, ""] - end - - i18n_default ||= "" - placeholder = I18n.t("#{object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.placeholder").presence - - placeholder ||= if object && object.class.respond_to?(:human_attribute_name) - object.class.human_attribute_name(method_and_value) - end - - placeholder ||= @method_name.humanize - - @options[:placeholder] = placeholder - end - end - end - end - end -end -- cgit v1.2.3 From fea7fe1fd2c7dbd98cf8707f9ecd17d010777fc1 Mon Sep 17 00:00:00 2001 From: Alex Robbin Date: Sat, 9 Aug 2014 00:10:54 -0400 Subject: add I18n support for `:placeholder` HTML option is passed to form fields --- .../action_view/helpers/tags/placeholderable.rb | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 actionview/lib/action_view/helpers/tags/placeholderable.rb (limited to 'actionview/lib/action_view/helpers/tags/placeholderable.rb') diff --git a/actionview/lib/action_view/helpers/tags/placeholderable.rb b/actionview/lib/action_view/helpers/tags/placeholderable.rb new file mode 100644 index 0000000000..313aa725c9 --- /dev/null +++ b/actionview/lib/action_view/helpers/tags/placeholderable.rb @@ -0,0 +1,32 @@ +module ActionView + module Helpers + module Tags # :nodoc: + module Placeholderable # :nodoc: + def initialize(*) + super + + if tag_value = @options[:placeholder] + object_name = @object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1') + method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}" + + if object.respond_to?(:to_model) + key = object.class.model_name.i18n_key + i18n_default = ["#{key}.#{method_and_value}".to_sym, ""] + end + + i18n_default ||= "" + placeholder = I18n.t("#{object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.placeholder").presence + + placeholder ||= if object && object.class.respond_to?(:human_attribute_name) + object.class.human_attribute_name(method_and_value) + end + + placeholder ||= @method_name.humanize + + @options[:placeholder] = placeholder + end + end + end + end + end +end -- cgit v1.2.3 From f99e62e2d9e010102788f1e728f54b03f65115c5 Mon Sep 17 00:00:00 2001 From: Alex Robbin Date: Fri, 22 Aug 2014 09:54:54 -0400 Subject: just use the placeholder tag value if it is passed as a String --- actionview/lib/action_view/helpers/tags/placeholderable.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionview/lib/action_view/helpers/tags/placeholderable.rb') diff --git a/actionview/lib/action_view/helpers/tags/placeholderable.rb b/actionview/lib/action_view/helpers/tags/placeholderable.rb index 313aa725c9..ae67bc13af 100644 --- a/actionview/lib/action_view/helpers/tags/placeholderable.rb +++ b/actionview/lib/action_view/helpers/tags/placeholderable.rb @@ -6,6 +6,8 @@ module ActionView super if tag_value = @options[:placeholder] + placeholder = tag_value if tag_value.is_a?(String) + object_name = @object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1') method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}" @@ -15,7 +17,7 @@ module ActionView end i18n_default ||= "" - placeholder = I18n.t("#{object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.placeholder").presence + placeholder ||= I18n.t("#{object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.placeholder").presence placeholder ||= if object && object.class.respond_to?(:human_attribute_name) object.class.human_attribute_name(method_and_value) -- cgit v1.2.3