Sha256: 3df1cf17344a021f35debe204541ed1628642c216da15ca1602f7a5effe42f37

Contents?: true

Size: 896 Bytes

Versions: 12

Compression:

Stored size: 896 Bytes

Contents

# TODO See if this can be refactored to make use of some of the Choices code.
module FormtasticBootstrap
  module Inputs
    class BooleanInput < Formtastic::Inputs::BooleanInput
      include Base

      def to_html
        clearfix_div_wrapping do
          empty_label <<
          hidden_field_html <<
          input_div_wrapping(:block) do
            template.content_tag(:ul, :class => "inputs-list") do
              template.content_tag(:li) do
                label_with_nested_checkbox
              end
            end
          end
        end
      end

      def label_text_with_embedded_checkbox
        # That newline matters!  Why, I do no not know.
        check_box_html << "\n" << template.content_tag(:span) do label_text end
      end

      # Need this for formatting to work.
      def empty_label
        template.content_tag(:label) do end
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
speedo-formstrap-1.2.7 lib/formtastic-bootstrap/inputs/boolean_input.rb
speedo-formstrap-1.2.6 lib/formtastic-bootstrap/inputs/boolean_input.rb
speedo-formstrap-1.2.5 lib/formtastic-bootstrap/inputs/boolean_input.rb
speedo-formstrap-1.2.4 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.2.0 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.1.2 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.1.1 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.1.0 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.0.3 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.0.2 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.0.1 lib/formtastic-bootstrap/inputs/boolean_input.rb
formtastic-bootstrap-1.0.0 lib/formtastic-bootstrap/inputs/boolean_input.rb