Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

nested_form shows extra fields after error messages #368

Open
Mingus85 opened this issue Feb 6, 2016 · 1 comment
Open

nested_form shows extra fields after error messages #368

Mingus85 opened this issue Feb 6, 2016 · 1 comment

Comments

@Mingus85
Copy link

Mingus85 commented Feb 6, 2016

I'm using simple_nested_form_for to build a form with nested fields. When I press submit, I get the correct params hash, and validation seems to work. When after some validations do not pass I re-render the form via the create action, however, the nested fields are displayed incorrectly. The same nested fields are shown multiple times.

Also, in my simple_fields_for the FormBuilder index is shown as a semi random number such as 1454793731550, whereas after re-rendering it is displayed in normal increments 0-n.

@Ashviniv
Copy link

Ashviniv commented Sep 22, 2016

@Mingus85 Can you please share your code?. especially, the create action of the controller. It is just to know what you are exactly trying to do.
And the last part is because , Using the nested form, we add fields dynamically, so for the first time when form is rendered, we donot initialize any objects of the child class. The FormBuilder object is yielded when usingform_for or fields_for. and When these values are submitted to server, we initialize objects so next time when it is re-render it is displayed with its object ids.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants