Sha256: 25b8537ea3ddcd8a42e06249b4cf2780c703459b5416d0e4098b4ed04d5a00eb

Contents?: true

Size: 1.3 KB

Versions: 23

Compression:

Stored size: 1.3 KB

Contents

module FlexaFormtasticBootstrap
  module Inputs
    module Base
      module Choices

        def input_div_wrapping(&block)
          template.content_tag(:div, choices_wrapping_html_options) do
            [yield, error_html(:block), hint_html(:block)].join("\n").html_safe  
          end
        end

        def choices_wrapping_html_options
          # TODO Call the Formtastic one explicity and append?
          { :class => "choices input" }
        end

        def choices_group_wrapping(&block)
          template.content_tag(:ul,
            template.capture(&block),
            choices_group_wrapping_html_options
          )
        end

        def choices_group_wrapping_html_options
          { :class => "choices-group inputs-list" }
        end

        def choice_label(choice)
          "\n".html_safe + template.content_tag(:span) do
            # (choice.is_a?(Array) ? choice.first : choice).to_s
            (choice.is_a?(Array) ? choice.first : choice).to_s
          end
        end

        # This is actually a label in Bootstrap.
        def legend_html
          template.content_tag(:label, label_html_options) do
            render_label? ? label_text : "".html_safe
          end
        end

        def label_html_options
          super.merge(:for => nil)
        end

      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
flexa_lib-0.5.2 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.5.1 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.5.0 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.9 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.8 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.7 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.6 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.5 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.4 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.3 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.2 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.1 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.3.0 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.9 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.8 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.7 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.6 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.5 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.4 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb
flexa_lib-0.2.3 lib/flexa_formtastic_bootstrap/inputs/base/choices.rb