Class: InputComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
Alveole::Concerns::Bem
Defined in:
lib/alveole/components/input_component.rb

Constant Summary collapse

MODIFIERS =
%i[disabled error].freeze

Instance Method Summary collapse

Methods included from Alveole::Concerns::Bem

#modifiers=

Constructor Details

#initialize(type: nil, label: nil, value: nil, form: nil, fieldname: nil, collection: nil, modifiers: [], options: {}) ⇒ InputComponent

Returns a new instance of InputComponent.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/alveole/components/input_component.rb', line 6

def initialize(type: nil, label: nil,
               value: nil,
               form: nil,
               fieldname: nil,
               collection: nil,
               modifiers: [],
               options: {})
  super

  @label = label
  @form = form
  @fieldname = fieldname
  @collection = collection
  @options = options
  @options[:value] = value if value
  @type = type || :text
  @error_message = error_message

  modifiers << :error if error?
  modifiers << :disabled if options[:disabled]
  self.modifiers = modifiers
end