Sha256: fc15b6de83fcdca8a00503e7f613f9ac8277766a244752c4b9db669a2190d29c
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
actionview-4.2.0.beta1 | lib/action_view/helpers/tags/placeholderable.rb |