Class: Trestle::Form::Fields::GroupedCollectionSelect
- Inherits:
-
Trestle::Form::Field
- Object
- Trestle::Form::Field
- Trestle::Form::Fields::GroupedCollectionSelect
- Defined in:
- lib/trestle/form/fields/grouped_collection_select.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#group_label_method ⇒ Object
readonly
Returns the value of attribute group_label_method.
-
#group_method ⇒ Object
readonly
Returns the value of attribute group_method.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#option_key_method ⇒ Object
readonly
Returns the value of attribute option_key_method.
-
#option_value_method ⇒ Object
readonly
Returns the value of attribute option_value_method.
Attributes inherited from Trestle::Form::Field
#block, #builder, #name, #options, #template
Instance Method Summary collapse
- #default_html_options ⇒ Object
- #field ⇒ Object
-
#initialize(builder, template, name, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ GroupedCollectionSelect
constructor
A new instance of GroupedCollectionSelect.
Methods inherited from Trestle::Form::Field
#defaults, #disabled?, #errors, #form_group, #normalize_options!, #readonly?, #render
Constructor Details
#initialize(builder, template, name, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) ⇒ GroupedCollectionSelect
Returns a new instance of GroupedCollectionSelect.
7 8 9 10 11 12 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 7 def initialize(builder, template, name, collection, group_method, group_label_method, option_key_method, option_value_method, ={}, ={}) super(builder, template, name, ) @collection, @group_method, @group_label_method, @option_key_method, @option_value_method = collection, group_method, group_label_method, option_key_method, option_value_method @html_options = .merge() end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 5 def collection @collection end |
#group_label_method ⇒ Object (readonly)
Returns the value of attribute group_label_method.
5 6 7 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 5 def group_label_method @group_label_method end |
#group_method ⇒ Object (readonly)
Returns the value of attribute group_method.
5 6 7 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 5 def group_method @group_method end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
5 6 7 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 5 def @html_options end |
#option_key_method ⇒ Object (readonly)
Returns the value of attribute option_key_method.
5 6 7 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 5 def option_key_method @option_key_method end |
#option_value_method ⇒ Object (readonly)
Returns the value of attribute option_value_method.
5 6 7 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 5 def option_value_method @option_value_method end |
Instance Method Details
#default_html_options ⇒ Object
18 19 20 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 18 def Trestle::Options.new(class: ["form-select"], disabled: disabled? || readonly?, data: { controller: "select" }) end |
#field ⇒ Object
14 15 16 |
# File 'lib/trestle/form/fields/grouped_collection_select.rb', line 14 def field builder.raw_grouped_collection_select(name, collection, group_method, group_label_method, option_key_method, option_value_method, , ) end |