Sha256: abced93b181f7f0c450b8371e654d82c9162e6f450fee337ad8a76b04e53626e

Contents?: true

Size: 1017 Bytes

Versions: 13

Compression:

Stored size: 1017 Bytes

Contents

module Trestle
  class Form
    module Fields
      class CollectionCheckBoxes < Field
        attr_reader :collection, :value_method, :text_method, :html_options

        def initialize(builder, template, name, collection, value_method, text_method, options={}, html_options={})
          super(builder, template, name, options)

          @collection, @value_method, @text_method = collection, value_method, text_method
          @html_options = default_html_options.merge(html_options)
        end

        def field
          content_tag(:div, class: "checkboxes") do
            builder.raw_collection_check_boxes(name, collection, value_method, text_method, options, html_options) do |b|
              b.label(class: "checkbox-inline") { b.check_box + b.text }
            end
          end
        end

        def default_html_options
          Trestle::Options.new
        end
      end
    end
  end
end

Trestle::Form::Builder.register(:collection_check_boxes, Trestle::Form::Fields::CollectionCheckBoxes)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trestle-0.8.13 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.12 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.11 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.10 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.9 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.8 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.7 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.6 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.5 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.4 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.3 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.2 lib/trestle/form/fields/collection_check_boxes.rb
trestle-0.8.0 lib/trestle/form/fields/collection_check_boxes.rb