Class: Input
- Inherits:
-
Object
- Object
- Input
- Includes:
- HasHelpers::Attributes, HasHelpers::UIAttributes
- Defined in:
- lib/has_helpers/utils/input.rb
Overview
Represents a user input on a form.
Input.new(:name => "Find")
If service is set in addition to name or value the submit will
be wrapped in a form element.
Constant Summary collapse
- DEFAULT_TYPE =
:submit
Instance Attribute Summary collapse
-
#actions ⇒ Object
writeonly
Sets the attribute actions.
- #label ⇒ Object
-
#name ⇒ Object
Returns the value of attribute name.
- #type ⇒ Object
- #value ⇒ Object
Attributes included from HasHelpers::UIAttributes::HTMLAttributes
Instance Method Summary collapse
- #to_action ⇒ Object
- #to_input ⇒ Object
-
#to_partial_path ⇒ Object
ActiveModel interface.
Methods included from HasHelpers::Attributes::GuardedAttributes
Methods included from HasHelpers::UIAttributes::HTMLAttributes
Methods included from HasHelpers::Attributes
Instance Attribute Details
#actions=(value) ⇒ Object (writeonly)
Sets the attribute actions
15 16 17 |
# File 'lib/has_helpers/utils/input.rb', line 15 def actions=(value) @actions = value end |
#label ⇒ Object
18 19 20 |
# File 'lib/has_helpers/utils/input.rb', line 18 def label @label || name.to_s.titleize end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/has_helpers/utils/input.rb', line 16 def name @name end |
#type ⇒ Object
42 43 44 |
# File 'lib/has_helpers/utils/input.rb', line 42 def type @type ||= DEFAULT_TYPE end |
#value ⇒ Object
22 23 24 |
# File 'lib/has_helpers/utils/input.rb', line 22 def value @value || name end |
Instance Method Details
#to_action ⇒ Object
33 34 35 |
# File 'lib/has_helpers/utils/input.rb', line 33 def to_action ::Action.new(input: self) end |
#to_input ⇒ Object
29 30 31 |
# File 'lib/has_helpers/utils/input.rb', line 29 def to_input self end |
#to_partial_path ⇒ Object
ActiveModel interface
38 39 40 |
# File 'lib/has_helpers/utils/input.rb', line 38 def to_partial_path "has_helpers/inputs/input" end |