Class: ActionView::Helpers::InstanceTag

Inherits:
Object
  • Object
show all
Defined in:
lib/hooks/helpers/instance_tag.rb

Instance Method Summary collapse

Instance Method Details

#to_input_field_tag(field_type, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/hooks/helpers/instance_tag.rb', line 2

def to_input_field_tag(field_type, options = {})
  options = options.stringify_keys
  options["size"] = options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"] unless options.key?("size")
  options = DEFAULT_FIELD_OPTIONS.merge(options)
  if field_type == "hidden"
    options.delete("size")
  end
  options["type"] = field_type
  if (field_type != "file")
    options["value"] = value_before_type_cast(object) unless !value_before_type_cast(object)
  end
  add_default_name_and_id(options)
  tag("input", options)
end