Class: Admin::SwitchComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Admin::SwitchComponent
- Defined in:
- lib/generators/infold/templates/install/app/components/admin/switch_component.rb
Instance Method Summary collapse
-
#initialize(form, field, include_hidden: true) ⇒ SwitchComponent
constructor
A new instance of SwitchComponent.
- #switch ⇒ Object
Constructor Details
#initialize(form, field, include_hidden: true) ⇒ SwitchComponent
Returns a new instance of SwitchComponent.
5 6 7 8 9 |
# File 'lib/generators/infold/templates/install/app/components/admin/switch_component.rb', line 5 def initialize(form, field, include_hidden: true) @form = form @field = field @include_hidden = include_hidden end |
Instance Method Details
#switch ⇒ Object
11 12 13 14 15 |
# File 'lib/generators/infold/templates/install/app/components/admin/switch_component.rb', line 11 def switch classes = %W(form-check-input) classes << 'is-invalid' if helpers.admin_field_invalid?(@form, @field) @form.check_box(@field, class: classes.join(' '), include_hidden: @include_hidden) end |