Class: Superform::Rails::Components::Input
- Inherits:
-
Field
- Object
- Base
- Field
- Superform::Rails::Components::Input
show all
- Defined in:
- lib/superform/rails/components/input.rb
Instance Attribute Summary
Attributes inherited from Base
#dom, #field
Instance Method Summary
collapse
Methods inherited from Base
#focus, #initialize
Instance Method Details
#field_attributes ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/superform/rails/components/input.rb', line 9
def field_attributes
{
id: dom.id,
name: dom.name,
type: type,
value: value
}
end
|
#has_client_provided_value? ⇒ Boolean
18
19
20
21
22
23
24
25
|
# File 'lib/superform/rails/components/input.rb', line 18
def has_client_provided_value?
case type.to_s
when "file", "image"
true
else
false
end
end
|
#type ⇒ Object
31
32
33
|
# File 'lib/superform/rails/components/input.rb', line 31
def type
@type ||= ActiveSupport::StringInquirer.new(attribute_type || value_type)
end
|
#value ⇒ Object
27
28
29
|
# File 'lib/superform/rails/components/input.rb', line 27
def value
dom.value unless has_client_provided_value?
end
|
#view_template ⇒ Object
5
6
7
|
# File 'lib/superform/rails/components/input.rb', line 5
def view_template(&)
input(**attributes)
end
|