Sha256: a05f244091d8c0e5310be1889c763a4567274a59da9421eaddbcdc92ef62050f

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

module Trestle
  class Form
    module Fields
      class GroupedCollectionSelect < Field
        attr_reader :collection, :group_method, :group_label_method, :option_key_method, :option_value_method, :html_options

        def initialize(builder, template, name, collection, group_method, group_label_method, option_key_method, option_value_method, options={}, html_options={})
          super(builder, template, name, options)

          @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 = default_html_options.merge(html_options)
        end

        def field
          builder.raw_grouped_collection_select(name, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
        end

        def default_html_options
          Trestle::Options.new(class: ["form-control"], data: { enable_select2: true })
        end
      end
    end
  end
end

Trestle::Form::Builder.register(:grouped_collection_select, Trestle::Form::Fields::GroupedCollectionSelect)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
trestle-0.9.3 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.9.2 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.9.1 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.9.0 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.13 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.12 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.11 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.10 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.9 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.8 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.7 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.6 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.5 lib/trestle/form/fields/grouped_collection_select.rb
trestle-0.8.4 lib/trestle/form/fields/grouped_collection_select.rb