Class: Irelia::Form::Base::Component

Inherits:
Component
  • Object
show all
Defined in:
app/components/irelia/form/base/component.rb

Instance Method Summary collapse

Instance Method Details

#error_messagesObject



40
41
42
# File 'app/components/irelia/form/base/component.rb', line 40

def error_messages
  errors&.join(", ")
end

#errorsObject



36
37
38
# File 'app/components/irelia/form/base/component.rb', line 36

def errors
  object ? object.errors[method] : []
end

#group_componentObject



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

Returns:

  • (Boolean)


44
45
46
# File 'app/components/irelia/form/base/component.rb', line 44

def has_errors?
  errors&.any?
end

#has_hint?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/components/irelia/form/base/component.rb', line 48

def has_hint?
  hint_text.present?
end

#hint_textObject



13
14
15
# File 'app/components/irelia/form/base/component.rb', line 13

def hint_text
  options[:hint]
end

#input_optionsObject



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_textObject



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

#valueObject



23
24
25
# File 'app/components/irelia/form/base/component.rb', line 23

def value
  object&.send(method)
end