Class: Forms::CollectionCheckBox

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
lib/forms/collection_check_box.rb

Overview

A single checkbox within a collection_check_boxes group.

Instance Method Summary collapse

Constructor Details

#initialize(name:, id:, value:, checked:, **options) ⇒ CollectionCheckBox

Returns a new instance of CollectionCheckBox.



6
7
8
9
10
11
12
13
# File 'lib/forms/collection_check_box.rb', line 6

def initialize(name:, id:, value:, checked:, **options)
  @name = name
  @id = id
  @value = value
  @checked = checked
  @options = options
  super()
end

Instance Method Details

#view_templateObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/forms/collection_check_box.rb', line 15

def view_template
  input(
    type: "checkbox",
    name: @name,
    id: @id,
    value: @value,
    class: @options[:class] || "checkbox",
    checked: @checked || nil
  )
end