Class: Input

Inherits:
Object
  • Object
show all
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

Attributes included from HasHelpers::UIAttributes::HTMLAttributes

#data, #skin

Instance Method Summary collapse

Methods included from HasHelpers::Attributes::GuardedAttributes

included

Methods included from HasHelpers::UIAttributes::HTMLAttributes

#raw_html_attrs

Methods included from HasHelpers::Attributes

included

Instance Attribute Details

#actions=(value) ⇒ Object (writeonly)

Sets the attribute actions

Parameters:

  • value

    the value to set the attribute actions to.



15
16
17
# File 'lib/has_helpers/utils/input.rb', line 15

def actions=(value)
  @actions = value
end

#labelObject



18
19
20
# File 'lib/has_helpers/utils/input.rb', line 18

def label
  @label || name.to_s.titleize
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/has_helpers/utils/input.rb', line 16

def name
  @name
end

#typeObject



42
43
44
# File 'lib/has_helpers/utils/input.rb', line 42

def type
  @type ||= DEFAULT_TYPE
end

#valueObject



22
23
24
# File 'lib/has_helpers/utils/input.rb', line 22

def value
  @value || name
end

Instance Method Details

#to_actionObject



33
34
35
# File 'lib/has_helpers/utils/input.rb', line 33

def to_action
  ::Action.new(input: self)
end

#to_inputObject



29
30
31
# File 'lib/has_helpers/utils/input.rb', line 29

def to_input
  self
end

#to_partial_pathObject

ActiveModel interface



38
39
40
# File 'lib/has_helpers/utils/input.rb', line 38

def to_partial_path
  "has_helpers/inputs/input"
end