Class: ActionForm::Input
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- ActionForm::Input
- Defined in:
- lib/action_form/input.rb
Overview
Represents a form element with input/output configuration and HTML attributes
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#html_attributes ⇒ Object
readonly
Returns the value of attribute html_attributes.
Instance Method Summary collapse
-
#initialize(element, **html_attributes) ⇒ Input
constructor
A new instance of Input.
- #view_template ⇒ Object
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
#element ⇒ Object (readonly)
Returns the value of attribute element.
6 7 8 |
# File 'lib/action_form/input.rb', line 6 def element @element end |
#html_attributes ⇒ Object (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_template ⇒ Object
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 |