Class: Forms::CollectionLabel

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

Overview

A label for a single collection checkbox item.

Instance Method Summary collapse

Constructor Details

#initialize(for_id:, text:, **options, &block) ⇒ CollectionLabel

Returns a new instance of CollectionLabel.



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

def initialize(for_id:, text:, **options, &block)
  @for_id = for_id
  @text = text
  @options = options
  @block = block
  super()
end

Instance Method Details

#view_templateObject



14
15
16
17
18
# File 'lib/forms/collection_label.rb', line 14

def view_template
  label(for: @for_id, class: @options[:class]) do
    @block ? yield_content(&@block) : plain(@text)
  end
end