lib/formtastic/helpers/inputs_helper.rb in formtastic-2.1.0.beta1 vs lib/formtastic/helpers/inputs_helper.rb in formtastic-2.1.0.rc

- old
+ new

@@ -368,20 +368,27 @@ fields_for_block = if block_given? raise ArgumentError, 'You gave :for option with a block to inputs method, ' << 'but the block does not accept any argument.' if block.arity <= 0 lambda do |f| - contents = f.inputs(*args){ block.call(f) } + contents = f.inputs(*args) do + if block.arity == 1 # for backwards compatibility with REE & Ruby 1.8.x + block.call(f) + else + index = parent_child_index(options[:parent]) if options[:parent] + block.call(f, index) + end + end template.concat(contents) end else lambda do |f| contents = f.inputs(*args) template.concat(contents) end end - fields_for_args = [options.delete(:for), options.delete(:for_options) || {}].flatten + fields_for_args = [options.delete(:for), options.delete(:for_options) || {}].flatten(1) fields_for(*fields_for_args, &fields_for_block) end def field_set_title_from_args(*args) #:nodoc: options = args.extract_options!