Sha256: 790e51680277adb72432e3f6df9b8d4788b00f56eb10f041b18ddb7da357ad97

Contents?: true

Size: 1 KB

Versions: 13

Compression:

Stored size: 1 KB

Contents

module Trestle
  class Form
    module Fields
      class CollectionRadioButtons < 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: "radio-buttons") do
            builder.raw_collection_radio_buttons(name, collection, value_method, text_method, options, html_options) do |b|
              b.label(class: "radio-inline") { b.radio_button + b.text }
            end
          end
        end

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

Trestle::Form::Builder.register(:collection_radio_buttons, Trestle::Form::Fields::CollectionRadioButtons)

Version data entries

13 entries across 13 versions & 1 rubygems

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