Class: FormProps::Inputs::TextField

Inherits:
Base
  • Object
show all
Includes:
ActionView::Helpers::Tags::Placeholderable
Defined in:
lib/form_props/inputs/text_field.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #json

Constructor Details

This class inherits a constructor from FormProps::Inputs::Base

Instance Method Details

#renderObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/form_props/inputs/text_field.rb', line 10

def render
  @options[:size] = @options[:max_length] unless @options.key?(:size)
  @options[:type] ||= field_type
  @options[:value] = @options.fetch(:value) { value_before_type_cast } unless field_type == "file"

  json.set!(sanitized_key) do
    add_default_name_and_id(@options)
    input_props(@options)
  end
end