Sha256: 4a4cdafeff7dde1f813d0c29bcbea6fe33b161844959c80d8245a3872c6a22ca

Contents?: true

Size: 1.52 KB

Versions: 11

Compression:

Stored size: 1.52 KB

Contents

module FormtasticBootstrap
  module Inputs
    module Base
      module Wrapping

        include Formtastic::Inputs::Base::Wrapping

        def generic_input_wrapping(&block)
          clearfix_div_wrapping do
            label_html <<
            input_div_wrapping do
              yield
            end
          end
        end

        def clearfix_div_wrapping(&block)
          template.content_tag(:div, wrapper_html_options) do
            yield
          end
        end

        def input_div_wrapping(inline_or_block_errors = :inline)
          template.content_tag(:div, :class => "input") do 
            [yield, error_html(inline_or_block_errors), hint_html(inline_or_block_errors)].join("\n").html_safe  
          end
        end

        def inline_inputs_div_wrapping(&block)
          template.content_tag(:div, :class => "inline-inputs") do
            yield
          end
        end

        def wrapper_html_options
          opts = options[:wrapper_html] || {}
          opts[:class] ||= []
          opts[:class] = [opts[:class].to_s] unless opts[:class].is_a?(Array)
          opts[:class] << as
          opts[:class] << "clearfix"
          # opts[:class] << "input"
          opts[:class] << "error" if errors?
          opts[:class] << "optional" if optional?
          opts[:class] << "required" if required?
          opts[:class] << "autofocus" if autofocus?
          opts[:class] = opts[:class].join(' ')
        
          opts[:id] ||= wrapper_dom_id
      
          opts
        end

      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

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