Sha256: 9245b9df9258519ba6da4aa0fb7098036797a8f4801585e6d4b08d76fbb7a050

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 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"])
          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

4 entries across 4 versions & 2 rubygems

Version Path
challah-1.0.0 vendor/bundle/gems/actionpack-4.0.0/lib/action_view/helpers/tags/text_field.rb
actionpack-4.0.0 lib/action_view/helpers/tags/text_field.rb
actionpack-4.0.0.rc2 lib/action_view/helpers/tags/text_field.rb
actionpack-4.0.0.rc1 lib/action_view/helpers/tags/text_field.rb