Flowdock
fields_for(record_name, record_object = nil, fields_options = {}, &block) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actionpack/lib/action_view/helpers/form_helper.rb, line 1293
      def fields_for(record_name, record_object = nil, fields_options = {}, &block)
        fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
        fields_options[:builder] ||= options[:builder]
        fields_options[:parent_builder] = self
        fields_options[:namespace] = fields_options[:parent_builder].options[:namespace]

        case record_name
        when String, Symbol
          if nested_attributes_association?(record_name)
            return fields_for_with_nested_attributes(record_name, record_object, fields_options, block)
          end
        else
          record_object = record_name.is_a?(Array) ? record_name.last : record_name
          record_name   = ActiveModel::Naming.param_key(record_object)
        end

        index = if options.has_key?(:index)
          "[#{options[:index]}]"
        elsif defined?(@auto_index)
          self.object_name = @object_name.to_s.sub(/\[\]$/,"")
          "[#{@auto_index}]"
        end
        record_name = "#{object_name}#{index}[#{record_name}]"

        @template.fields_for(record_name, record_object, fields_options, &block)
      end
Register or log in to add new notes.