Sha256: 7c37ad6c10e5b74690d2ef134a21dfe29052567dd3efa0c0d5b63ba7c7ba5930

Contents?: true

Size: 845 Bytes

Versions: 4

Compression:

Stored size: 845 Bytes

Contents

module BootstrapForms
  module Helpers
    module FormHelper
      def bootstrap_form_for(record, options = {}, &block)
        options[:builder] ||= BootstrapForms.default_form_builder

        form_options = options.deep_dup
        options[:summary_errors] = true unless form_options.has_key?(:summary_errors)
        form_options.delete(:summary_errors)

        form_for(record, form_options) do |f|
          if f.object.respond_to?(:errors) and options[:summary_errors]
            f.error_messages.html_safe + capture(f, &block).html_safe
          else
            capture(f, &block).html_safe
          end
        end
      end

      def bootstrap_fields_for(record, options = {}, &block)
        options[:builder] ||= BootstrapForms.default_form_builder

        fields_for(record, nil, options, &block)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bootstrap_forms-4.0.1 lib/bootstrap_forms/helpers/form_helper.rb
bootstrap_forms-4.0.0 lib/bootstrap_forms/helpers/form_helper.rb
bootstrap_forms-3.0.1 lib/bootstrap_forms/helpers/form_helper.rb
bootstrap_forms-3.0.0 lib/bootstrap_forms/helpers/form_helper.rb