Class: Trestle::Form::Fields::CollectionCheckBoxes
- Inherits:
-
Trestle::Form::Field
- Object
- Trestle::Form::Field
- Trestle::Form::Fields::CollectionCheckBoxes
- Includes:
- CheckBoxHelpers
- Defined in:
- lib/trestle/form/fields/collection_check_boxes.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#text_method ⇒ Object
readonly
Returns the value of attribute text_method.
-
#value_method ⇒ Object
readonly
Returns the value of attribute value_method.
Attributes inherited from Trestle::Form::Field
#block, #builder, #name, #options, #template
Instance Method Summary collapse
- #default_html_options ⇒ Object
- #defaults ⇒ Object
- #field ⇒ Object
-
#initialize(builder, template, name, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ CollectionCheckBoxes
constructor
A new instance of CollectionCheckBoxes.
Methods included from CheckBoxHelpers
#default_wrapper_class, #inline?, #input_class, #label_class, #switch?
Methods inherited from Trestle::Form::Field
#disabled?, #errors, #form_group, #normalize_options!, #readonly?, #render
Constructor Details
#initialize(builder, template, name, collection, value_method, text_method, options = {}, html_options = {}, &block) ⇒ CollectionCheckBoxes
Returns a new instance of CollectionCheckBoxes.
9 10 11 12 13 14 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 9 def initialize(builder, template, name, collection, value_method, text_method, ={}, ={}, &block) super(builder, template, name, , &block) @collection, @value_method, @text_method = collection, value_method, text_method @html_options = .merge() end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
7 8 9 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 7 def collection @collection end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
7 8 9 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 7 def @html_options end |
#text_method ⇒ Object (readonly)
Returns the value of attribute text_method.
7 8 9 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 7 def text_method @text_method end |
#value_method ⇒ Object (readonly)
Returns the value of attribute value_method.
7 8 9 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 7 def value_method @value_method end |
Instance Method Details
#default_html_options ⇒ Object
32 33 34 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 32 def Trestle::Options.new end |
#defaults ⇒ Object
28 29 30 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 28 def defaults super.merge(inline: true) end |
#field ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/trestle/form/fields/collection_check_boxes.rb', line 16 def field builder.raw_collection_check_boxes(name, collection, value_method, text_method, , ) do |b| if block block.call(b) else tag.div(class: default_wrapper_class) do b.check_box(class: input_class) + b.label(class: label_class) { b.text } end end end end |