-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Duplicate names of ngModel fields in form controller not supported. #12200
Comments
You should use a different name for each field. Since you are using <form name="myForm">
<div ng-repeat="item in items">
<input ng-model="item.name" name="name{{$index}}">
</div>
</form> |
Since multiple form elements with the same name are accessible as an array in form.elements[inputName], maybe angular should do the same? |
I've found a way to achieve my goal anyway. But I still think it would be very helpful to access elements with the same name as an array. |
Definitely somewhat confusing when first encountering this issue. If there was an interpolation step in the |
@booleanbetrayal, (as already mentioned above) there is. |
Ahh, I was confused about some of the formController method parameters, and looks like they accept a |
Not sure what you mean, but if you're happy, I'm happy 😛 |
Hi, I'm having the same issue. I got an ng-form inside of an ng-repeat. I got 2 inputs in this form ng-model="feat.Name" and ng-model="feat.Description". The thing is that all inputs are being updated when I type somehting. How can I avoid this behavior? I added to the inputs name=name{{$index}} and it didnt work, also I added that index to the ng-model but then the ng-repeat didnt work. Any help? thanks |
@AcarMeel, this sounds like a general support question. Please, use one of the appropriate support channels for these types of questions. Thx! |
In 1.0.0rc2, a form supports multiple fields to have the same name.
For example:
We can access the array of ngModelControllers by
But all versions after that, a form can only register a single modelController with the same name.
In the example above, myForm.name is the last item in the items array, which replaces all others.
Is there a way to access a certain group of fields on the form controller level like
?
I am trying to validate against uniqueness over multiple fields in a form.
The text was updated successfully, but these errors were encountered: