nested_form icon indicating copy to clipboard operation
nested_form copied to clipboard

Javascript fails to generate correct html for doubly nested forms

Open Mysrt opened this issue 12 years ago • 5 comments

If you have a doubly nested creation form, the javascript will incorrectly strip out the name of the second association and replace it with an integer, breaking the form. Also i think this fixes issue #26.

Mysrt avatar Jan 22 '13 21:01 Mysrt

We can't remove this javascript code because it's here in order to generate correct input names. We even have the test failing with your patch.

Could you please push a test application reproducing this issue? Thanks!

lest avatar Jan 23 '13 08:01 lest

I have the same problem and made a test application for it.

https://github.com/basvanwesting/nested_form_issues_228.git see branch 'free_format'

  • commit f7800ed: working example with 3 levels of nesting, so issue the doesn't always occur and is more specific
  • commit e026a5: working example in a more complex setup with 2 levels of nesting
  • commit 29f5d14: failing example in a more complex setup with 3 levels of nesting

basvanwesting avatar Feb 02 '13 14:02 basvanwesting

In the test application (branch 'free_format') I found a workaround for the problem:

  • commit 1bda69a: change has_one to has_many: solving the failing test of commit 29f5d14

Apparently the problem resides in the has_one relation. Changing this to has_many solves the issue for me. So this issue might be related to #124 and #125.

basvanwesting avatar Feb 03 '13 07:02 basvanwesting

I applied patch #125 and this solves the issue in commit 29f5d1 for me. The patch no longer applies directly because of some refactoring in nested_form. I'll make a fork and apply the patch in it's new form.

basvanwesting avatar Feb 03 '13 07:02 basvanwesting

added pull request: https://github.com/ryanb/nested_form/pull/232

basvanwesting avatar Feb 03 '13 10:02 basvanwesting