-
Notifications
You must be signed in to change notification settings - Fork 506
Nested inputs are being generated with the same name attribute #359
Comments
I have the same issue here with every time the id "0" generated, did you find a solution? |
@elomarns and @loicginoux Yes, I fixed this! issue last night. It took whole day to understand the reason! I am going to create pull request. |
I went to create a new pull request, however before do that I checked that anyone has created any PR regarding an issue and found that this issue has been fixed by this PR, #278 I believe when this PR will merge then all issue related this will fix also. |
The #278 build is failing in Travis CI and I do not think @ryanb will merge the PR. @naimrajib07 could you create the PR with your fix? |
@naimrajib07 @twnaing I have the same issue too. Can you please create a PR or share your code here? |
I'm having this same issue, 5 years later. Does this gem not support a double-nested form (one => many => many)? All my inputs have names with index [0]... |
I'm building an application where users can create surveys and add questions to them. A question can have many possible answers, each one being represented as a radio button for its parent question when the survey is being answered. However, possible answers can also have questions. In this case, these questions are conditional questions. They will be shown only if its parent possible answer were selected when someone answered that question.
These are the models which implement this structure:
However, when I add a possible answer to a conditional question, each nested input generated has the same name attribute. For example:
I believe the problem is on the following snippet from jquery_nested_form.js:
jquery_nested_form.js creates a variable named content, which contains the template for the new nested fields. This variable doesn't have ids, instead it presentes its associations as "new_association". So the above snippet of code takes the current ids from the context, and replace it on the content variable. But in my case, I have the following string for the actual input on the content variable:
And this is the context:
"survey[questions_attributes][0][possible_answers_attributes][1442422446853][conditional_question_attributes]"
On the content variable, the "new_possible_answer" string appears after a question and also after a conditional question on the name attribute. So each possible answer added for a conditional question receives the same id of the previous possible answer, instead of receiving a new id.
The text was updated successfully, but these errors were encountered: