Class: ActionView::Helpers::AttributeBuilders::TextField

Inherits:
Base
  • Object
show all
Includes:
Tags::Placeholderable
Defined in:
lib/actionview_attribute_builders/attribute_builders/text_field.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Base

#object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ActionView::Helpers::AttributeBuilders::Base

Class Method Details

.field_typeObject



22
23
24
# File 'lib/actionview_attribute_builders/attribute_builders/text_field.rb', line 22

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

Instance Method Details

#html_attributesObject



11
12
13
14
15
16
17
18
19
# File 'lib/actionview_attribute_builders/attribute_builders/text_field.rb', line 11

def html_attributes
  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 } unless field_type == "file"
  add_default_name_and_id(options)
  
  return options
end