Sha256: 446d03ba10117df5d7a16b8bb109f867522a46f0fad24d0026bfca321faa5ad3

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

module BootstrapForm
  module Helper
    def bootstrap_form_for(object, options = {}, &block)
      options[:builder] = BootstrapForm::FormBuilder

      style = case options[:style]
        when :inline
          "form-inline"
        when :horizontal
          "form-horizontal"
      end

      if style
        options[:html] ||= {}
        options[:html][:class] = "#{options[:html][:class]} #{style}".lstrip
      end

      temporarily_disable_field_error_proc do
        form_for(object, options, &block)
      end
    end

    def temporarily_disable_field_error_proc
      original_proc = ActionView::Base.field_error_proc
      ActionView::Base.field_error_proc = proc { |input, instance| input }
      yield
    ensure
      ActionView::Base.field_error_proc = original_proc
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap_form-2.0.1 lib/bootstrap_form/helper.rb
bootstrap_form-2.0.0 lib/bootstrap_form/helper.rb