Ticket #360 (closed defect: fixed)

Opened 10 months ago

Last modified 9 months ago

[PATCH] Nesting fields_for bug

Reported by: tpitale+me..@gmail.com Assigned to:
Priority: medium Milestone: The Future
Component: Plugins Keywords: form, helpers, plugin
Cc:

Description

When nesting fields_for within form_for in order to combine two objects into one form, the form_for object should be used again after the end of the fields_for block. Instead, the object from fields_for is used for the remainder of the form_for, at least in naming and id-ing the fields.

http://pastie.caboo.se/128038 example erb http://pastie.caboo.se/128041 resulting form

Attachments

fix_form_helper_scope.patch (1.7 kB) - added by j.naga..@gmail.com on 01/08/08 12:15:08.
fix_form_helper_scope_2.patch (1.8 kB) - added by j.naga..@gmail.com on 01/08/08 12:19:43.

Change History

12/13/07 09:38:15 changed by tpitale+me..@gmail.com

The problem is not that the object isn't reset after returning from a block in fields_for but rather, the object_name is not reset. So, when it is used in a form, the wrong object name is applied as the field's name and/or id.

To fix, simply add..@_object_name = "..@_obj.class}".snake_case

again, after the block, as the last line in the fields_for method.

01/08/08 12:14:42 changed by j.naga..@gmail.com

  • summary changed from Nesting fields_for bug to [PATCH] Nesting fields_for bug.

I've fixed this, patch attached.

There is still a failing spec in merb_helpers.

01/08/08 12:15:08 changed by j.naga..@gmail.com

  • attachment fix_form_helper_scope.patch added.

01/08/08 12:19:43 changed by j.naga..@gmail.com

  • attachment fix_form_helper_scope_2.patch added.

01/09/08 00:04:29 changed by has.s..@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

(In [1223]) Fixes object naming for nested fileds_for. Closes #360