Class: ActionForm::Input

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
lib/action_form/input.rb

Overview

Represents a form element with input/output configuration and HTML attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, **html_attributes) ⇒ Input

Returns a new instance of Input.



8
9
10
11
12
# File 'lib/action_form/input.rb', line 8

def initialize(element, **html_attributes)
  super()
  @element = element
  @html_attributes = html_attributes
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



6
7
8
# File 'lib/action_form/input.rb', line 6

def element
  @element
end

#html_attributesObject (readonly)

Returns the value of attribute html_attributes.



6
7
8
# File 'lib/action_form/input.rb', line 6

def html_attributes
  @html_attributes
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
# File 'lib/action_form/input.rb', line 14

def view_template
  if %i[checkbox radio select textarea].include?(element.input_type)
    send("render_#{element.input_type}")
  else
    input(**mix(element.input_html_attributes, html_attributes))
  end
end