Sha256: cc501bc3ba119941455390f0b50864ddabf0d7e357cca967b7ffacdf75dff664

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module FormtasticBootstrap
  module Inputs
    class CheckBoxesInput < Formtastic::Inputs::CheckBoxesInput
      include Base
      include Base::Choices

      # TODO Make sure help blocks work correctly.

      def to_html
        bootstrap_wrapping do
          hidden_field_for_all << # Might need to remove this guy.
          collection.map { |choice|
            choice_html(choice)
          }.join("\n").html_safe
        end
      end

      def choice_html(choice)
        checkbox_wrapping do
          template.content_tag(:label,
            hidden_fields? ?
              check_box_with_hidden_input(choice) :
              check_box_without_hidden_input(choice) <<
            choice_label(choice),
            label_html_options.merge(choice_label_html_options(choice))
          )
        end
      end

      def checkbox_wrapping(&block)
        class_name = "checkbox"
        class_name += " checkbox-inline" if options[:inline]
        template.content_tag(:div,
          template.capture(&block).html_safe,
          :class => class_name
        )
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
formtastic-bootstrap-3.1.1 lib/formtastic-bootstrap/inputs/check_boxes_input.rb
formtastic-bootstrap-3.1.0 lib/formtastic-bootstrap/inputs/check_boxes_input.rb