Sha256: 4597110e1f81d4e0cb3063bcb3c7a6171a5b8c741a650f297b80199bbea0e772

Contents?: true

Size: 832 Bytes

Versions: 2

Compression:

Stored size: 832 Bytes

Contents

require 'railsstrap/core_ext/rails/form/fieldset_helper'

module Railsstrap
  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

2 entries across 2 versions & 1 rubygems

Version Path
railsstrap-4.0.0.beta3 lib/railsstrap/core_ext/rails/form/fields_for_helper.rb
railsstrap-4.0.0.beta2 lib/railsstrap/core_ext/rails/form/fields_for_helper.rb