Sha256: ee85d1832145273f7c1fcc5a196da2bf89bf8ad2c94788cf6910ccfb13f83a36

Contents?: true

Size: 901 Bytes

Versions: 13

Compression:

Stored size: 901 Bytes

Contents

# TODO See if this can be refactored to make use of some of the Choices code.
module FlexaFormtasticBootstrap
  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

13 entries across 13 versions & 1 rubygems

Version Path
flexa_lib-0.3.2 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.3.1 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.3.0 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.9 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.8 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.7 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.6 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.5 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.4 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.3 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.2 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.1 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb
flexa_lib-0.2.0 lib/flexa_formtastic_bootstrap/inputs/boolean_input.rb