Sha256: 46b6ae57136ac8cdfc555170dec0c2ee83dd3373b4e4f810668bb22ac275be9e

Contents?: true

Size: 908 Bytes

Versions: 8

Compression:

Stored size: 908 Bytes

Contents

module SimpleForm
  module Components
    module Wrapper
      def wrap(content)
        if wrapper_tag && options[:wrapper] != false
          template.content_tag(wrapper_tag, content, wrapper_html_options)
        else
          content
        end
      end

      def wrapper_tag
        options[:wrapper_tag] || SimpleForm.wrapper_tag
      end

      def wrapper_class
        options[:wrapper_class] || SimpleForm.wrapper_class
      end

      def wrapper_error_class
        options[:wrapper_error_class] || SimpleForm.wrapper_error_class
      end

      def wrapper_html_options
        css_classes = input_html_classes.unshift(wrapper_class)
        css_classes << wrapper_error_class if has_errors?
        css_classes << disabled_class if disabled?
        html_options_for(:wrapper, css_classes)
      end

    private

      def disabled_class
        'disabled'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
simple_form-1.5.2 lib/simple_form/components/wrapper.rb
simple_form-1.5.1 lib/simple_form/components/wrapper.rb
simple_form-1.5.0 lib/simple_form/components/wrapper.rb
simple_form-1.4.2 lib/simple_form/components/wrapper.rb
simple_form-1.4.1 lib/simple_form/components/wrapper.rb
simple_form-1.4.0 lib/simple_form/components/wrapper.rb
simple_form-1.3.1 lib/simple_form/components/wrapper.rb
simple_form-1.3.0 lib/simple_form/components/wrapper.rb