Sha256: e9ed3ccbc8b2ce16a1ba2ab50d4ee75a779438796f7a6f4759d3d6dad49f4519

Contents?: true

Size: 816 Bytes

Versions: 7

Compression:

Stored size: 816 Bytes

Contents

require 'bh/core_ext/rails/form/fieldset_helper'

module Bh
  module Form
    module FieldsForHelper
      include BaseHelper
      include FieldsetHelper # for fieldset

      def fields_for(record_name, record_object = nil, fields_options = {}, &block)
        if record_object.is_a?(Hash) && record_object.extractable_options?
          record_object, fields_options = nil, record_object
        end

        fields_options[:layout] ||= @options[:layout]
        fields_options[:errors] ||= @options[:errors]
        title = fields_options.delete(:title) { record_name.to_s.humanize }
        wrap_in_fieldset = fields_options.fetch :fieldset, true
        fields = super record_name, record_object, fields_options, &block
        wrap_in_fieldset ? fieldset(title) { fields } : fields
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bh-1.3.6 lib/bh/core_ext/rails/form/fields_for_helper.rb
bh-1.3.5 lib/bh/core_ext/rails/form/fields_for_helper.rb
bh-1.3.4 lib/bh/core_ext/rails/form/fields_for_helper.rb
bh-1.3.3 lib/bh/core_ext/rails/form/fields_for_helper.rb
bh-1.3.1 lib/bh/core_ext/rails/form/fields_for_helper.rb
bh-1.3.0 lib/bh/core_ext/rails/form/fields_for_helper.rb
bh-1.2.0 lib/bh/core_ext/rails/form/fields_for_helper.rb