diff options
Diffstat (limited to 'actionview/lib/action_view/helpers/tags/placeholderable.rb')
-rw-r--r-- | actionview/lib/action_view/helpers/tags/placeholderable.rb | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/actionview/lib/action_view/helpers/tags/placeholderable.rb b/actionview/lib/action_view/helpers/tags/placeholderable.rb index 690ba93ab5..0b15a11308 100644 --- a/actionview/lib/action_view/helpers/tags/placeholderable.rb +++ b/actionview/lib/action_view/helpers/tags/placeholderable.rb @@ -7,26 +7,12 @@ module ActionView 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}" - if object.respond_to?(:to_model) - model = object.to_model - end - - if model - key = model.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 model && model.class.respond_to?(:human_attribute_name) - model.class.human_attribute_name(method_and_value) - end + placeholder ||= Tags::Translator + .new(object, @object_name, method_and_value, "helpers.placeholder") + .call placeholder ||= @method_name.humanize - @options[:placeholder] = placeholder end end |