Class: FormProps::Inputs::TextArea

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #json

Constructor Details

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

Class Method Details

.field_typeObject



25
26
27
# File 'lib/form_props/inputs/text_area.rb', line 25

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

Instance Method Details

#renderObject



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

def render
  json.set!(sanitized_key) do
    add_default_name_and_id(@options)
    @options[:type] ||= field_type
    @options[:value] = @options.fetch(:value) { value_before_type_cast }

    if (size = @options.delete(:size))
      @options[:cols], @options[:rows] = size.split("x") if size.respond_to?(:split)
    end

    input_props(@options)
  end
end