Sha256: e8a15a2300a60e72ed36db6a78a570db7c8dd402de03c73c384f4d621cb34efd

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

module SimpleForm
  class HorizontalFormBuilder < SimpleForm::DefaultFormBuilder
    CHECKBOX_WRAPPER = :horizontal_checkbox
    RADIO_WRAPPER = :horizontal_radio

    def buttons(options = {}, &block)
      raise ::ArgumentError unless block_given?
      options[:class] ||= 'col-sm-offset-3 col-sm-9 col-md-offset-3 col-md-9 col-lg-offset-2 col-lg-10'
      @template.content_tag(:div, class: 'form-group') do
        @template.content_tag(:div, class: options[:class]) do
          yield
        end
      end
    end

    def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
      raise ::ArgumentError, 'Inline is unsupported for horizontal form' if options.key? :inline
      options[:item_wrapper_class] ||= 'col-sm-offset-3 col-sm-9 col-md-offset-3 col-md-9 col-lg-offset-2 col-lg-10 checkbox'
      super
    end

    def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
      raise ::ArgumentError, 'Inline is unsupported for horizontal form' if options.key? :inline
      options[:item_wrapper_class] ||= 'col-sm-offset-3 col-sm-9 col-md-offset-3 col-md-9 col-lg-offset-2 col-lg-10 radio'
      super
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_form_bootstrap3-0.3.6 lib/simple_form/horizontal_form_builder.rb
simple_form_bootstrap3-0.3.5 lib/simple_form/horizontal_form_builder.rb
simple_form_bootstrap3-0.3.4 lib/simple_form/horizontal_form_builder.rb