Class: Practical::Views::Form::InputComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/practical/views/form/input_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f:, object_method:, label_options: {}) ⇒ InputComponent

Returns a new instance of InputComponent.



9
10
11
12
13
# File 'app/components/practical/views/form/input_component.rb', line 9

def initialize(f:, object_method:, label_options: {})
  self.f = f
  self.object_method = object_method
  self.label_options = label_options
end

Instance Attribute Details

#fObject

Returns the value of attribute f.



4
5
6
# File 'app/components/practical/views/form/input_component.rb', line 4

def f
  @f
end

#label_optionsObject

Returns the value of attribute label_options.



4
5
6
# File 'app/components/practical/views/form/input_component.rb', line 4

def label_options
  @label_options
end

#object_methodObject

Returns the value of attribute object_method.



4
5
6
# File 'app/components/practical/views/form/input_component.rb', line 4

def object_method
  @object_method
end

Instance Method Details

#field_errors_idObject



15
16
17
# File 'app/components/practical/views/form/input_component.rb', line 15

def field_errors_id
  f.field_errors_id(object_method)
end

#field_options(**options) ⇒ Object



19
20
21
# File 'app/components/practical/views/form/input_component.rb', line 19

def field_options(**options)
  mix({"aria-describedby": field_errors_id}, options)
end