Sha256: 34c15b83c520ec3db11484becc66576677c51379645de43e8d7bc53440c83edf

Contents?: true

Size: 1.66 KB

Versions: 17

Compression:

Stored size: 1.66 KB

Contents

module SimpleForm
  module ActionViewExtensions
    module BootstrapFormHelper
      def horizontal_form_for(object, *args, &block)
        options = args.extract_options!
        options[:wrapper] ||= :horizontal
        options[:builder] ||= SimpleForm::HorizontalFormBuilder
        options[:html] ||= {}
        options[:html][:role] = 'form'
        options[:html][:class] = [ options[:html][:class], 'form-horizontal' ].compact.join(' ')

        simple_form_for object, *(args << options), &block
      end

      def default_form_for(object, *args, &block)
        options = args.extract_options!
        options[:wrapper] ||= :default
        options[:builder] ||= SimpleForm::DefaultFormBuilder
        options[:html] ||= {}
        options[:html][:role] = 'form'

        simple_form_for object, *(args << options), &block
      end

      def compact_form_for(object, *args, &block)
        options = args.extract_options!
        options[:wrapper] ||= :default
        options[:builder] ||= SimpleForm::PlaceholderFormBuilder
        options[:html] ||= {}
        options[:html][:role] = 'form'

        simple_form_for object, *(args << options), &block
      end

      def inline_form_for(object, *args, &block)
        options = args.extract_options!
        options[:wrapper] ||= :inline
        options[:builder] ||= SimpleForm::InlineFormBuilder
        options[:html] ||= {}
        options[:html][:role] = 'form'
        options[:html][:class] = [ options[:html][:class], 'form-inline' ].compact.join(' ')

        simple_form_for object, *(args << options), &block
      end
    end
  end
end

ActionView::Base.send :include, SimpleForm::ActionViewExtensions::BootstrapFormHelper

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
simple_form_bootstrap3-0.3.6 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.3.5 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.3.4 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.3.3 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.3.2 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.3.1 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.3.0 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.9 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.8 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.7 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.6 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.5 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.4 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.3 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.2 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.1 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb
simple_form_bootstrap3-0.2.0 lib/simple_form/action_view_extensions/bootstrap_form_helper.rb