Class: Irelia::Form::Base::Component
- Inherits:
-
Component
- Object
- Component
- Irelia::Form::Base::Component
show all
- Defined in:
- app/components/irelia/form/base/component.rb
Instance Method Summary
collapse
Instance Method Details
#error_messages ⇒ Object
40
41
42
|
# File 'app/components/irelia/form/base/component.rb', line 40
def error_messages
errors&.join(", ")
end
|
#errors ⇒ Object
36
37
38
|
# File 'app/components/irelia/form/base/component.rb', line 36
def errors
object ? object.errors[method] : []
end
|
#group_component ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'app/components/irelia/form/base/component.rb', line 27
def group_component
Irelia::Form::Group::Component.new(
object: object,
object_name: object_name,
method: method,
options: options
)
end
|
#has_errors? ⇒ Boolean
44
45
46
|
# File 'app/components/irelia/form/base/component.rb', line 44
def has_errors?
errors&.any?
end
|
#has_hint? ⇒ Boolean
48
49
50
|
# File 'app/components/irelia/form/base/component.rb', line 48
def has_hint?
hint_text.present?
end
|
#hint_text ⇒ Object
13
14
15
|
# File 'app/components/irelia/form/base/component.rb', line 13
def hint_text
options[:hint]
end
|
17
18
19
20
21
|
# File 'app/components/irelia/form/base/component.rb', line 17
def input_options
html_options.merge(
value: value,
)
end
|
#label_text ⇒ Object
9
10
11
|
# File 'app/components/irelia/form/base/component.rb', line 9
def label_text
options[:label] || object&.class&.human_attribute_name(method)
end
|
#value ⇒ Object
23
24
25
|
# File 'app/components/irelia/form/base/component.rb', line 23
def value
object&.send(method)
end
|