Sha256: 96a6dc8bf4a5bfd66ed0a8b87eb4bf9440bc3d1ff05c2230066304ec16de2015

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

module ActionView
  module Helpers
    module Tags # :nodoc:
      class TextField < Base # :nodoc:
        def render
          options = @options.stringify_keys
          options["size"] = options["maxlength"] unless options.key?("size")
          options["type"] ||= field_type
          options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
          options["value"] &&= ERB::Util.html_escape(options["value"])
          yield options if block_given?
          add_default_name_and_id(options)
          tag("input", options)
        end

        class << self
          def field_type
            @field_type ||= self.name.split("::").last.sub("Field", "").downcase
          end
        end

        private

        def field_type
          self.class.field_type
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
actionpack-4.0.13 lib/action_view/helpers/tags/text_field.rb
actionpack-4.0.13.rc1 lib/action_view/helpers/tags/text_field.rb