Skip to content

Forms should throw error if two or more NgModels appear in form with the same name #13993

Closed as not planned

Description

@kemsky

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently there is no error or warning if two form controls have the same name:

<input name="entireStateCoverage" type="checkbox" [(ngModel)]="item.entireStateCoverage">
<input name="entireStateCoverage" type="checkbox" [(ngModel)]="item.active">

Expected behavior

Forms should throw error if duplicate names are detected.

What is the motivation / use case for changing the behavior?

This leads to unpredictable results (value overwrites) which are difficult to find.

  • Angular version: 2.4.3

  • Browser: [all]

  • Language: [all]

Activity

  1. added
    feature
    on Dec 19, 2017
  2. added this to the Backlog milestone on Jan 23, 2018
  3. angular-robot commented on Jun 4, 2021

    @angular-robot
    Contributor

    Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

    Find more details about Angular's feature request process in our documentation.

  4. angular-robot commented on Jun 25, 2021

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  5. added
    open for contributions
    good first issue
    on Jun 6, 2022
  6. dylhunn commented on Jun 6, 2022

    @dylhunn
    Contributor

    We'd likely accept a contribution in this area, and it's good for a first-time contributor. The message would go in forms/src/directives/template_driven_errors.ts, and the check would be somewhere in forms/src/directives.

  7. phalgunv commented on Jun 7, 2022

    @phalgunv
    Contributor

    I'd like to work on this issue.

  8. added
    feature: under consideration
    and removed on Jun 8, 2022
  9. phalgunv commented on Jun 8, 2022

    @phalgunv
    Contributor

    How do I build Angular source code? When I run npm install I get the below error:
    `PS C:\code\angular> npm install
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    npm ERR!
    npm ERR! While resolving: [email protected]
    npm ERR! Found: [email protected]
    npm ERR! node_modules/typescript
    npm ERR! typescript@"~4.7.2" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! peer typescript@">=4.4.2 <4.7" from @angular/[email protected]
    npm ERR! node_modules/@angular/compiler-cli
    npm ERR! peer @angular/compiler-cli@"^13.0.0 || ^13.3.0-rc.0" from @angular-devkit/[email protected]
    npm ERR! node_modules/@angular-devkit/build-angular
    npm ERR!
    npm ERR! Fix the upstream dependency conflict, or retry
    npm ERR! this command with --force, or --legacy-peer-deps
    npm ERR!

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:\Users\pvaddepa\AppData\Local\npm-cache_logs\2022-06-08T19_35_31_088Z-debug.log`

    Even npm install --force errors out. I am using node 16.10.0

    Please let me know what I'm missing.

  10. 13 remaining items

  11. vp4140 commented on Sep 7, 2023

    @vp4140

    Hey @dylhunn , I'm interested in continuing working on the above mentioned PR.

  12. tghimanshu commented on Sep 22, 2025

    @tghimanshu

    @kemsky, I acknowledge that the following issue is pretty old. But, while navigating the good-first-issue, I encountered these as open, so I wanted to check them out.
    I was trying the following code block, and it seems to not cause any concerns with the values.

    Prompting an error for the name property seems counterintuitive, as it's not being used to manage the values.
    Do we really require an error to notify it, or a warning, or ignoring might suffice?

    <input
      name="entireStateCoverage"
      type="checkbox"
      [(ngModel)]="title"
      #titleInput="ngModel"
    />
    <input
      name="entireStateCoverage"
      type="checkbox"
      [(ngModel)]="active"
      #activeInput="ngModel"
    />
    
    <div>{{ title }}</div>
    <div>{{ active }}</div>
    <div>---</div>
    <div>{{ titleInput.value }}</div>
    <div>{{ activeInput.value }}</div>
    @Component({
      selector: 'app-root',
      imports: [FormsModule],
      templateUrl: './app.component.html',
      styleUrl: './app.component.scss'
    })
    export class AppComponent {
      title = true;
      active = false;
    }

    I was able to use title and active checkboxes independently and without cross contamination of values.

  13. kemsky commented on Sep 22, 2025

    @kemsky
    Author

    @tghimanshu , I have no idea

  14. tghimanshu commented on Sep 22, 2025

    @tghimanshu

    Let's see if it's really needed. Thanks for the reply @kemsky

  15. added a commit that references this issue on Jun 14, 2026
    21acb65
  16. LeonxLJX commented on Sep 1, 2026

    @LeonxLJX

    I'd like to take this one (Forms should throw error if two or more NgModels appear in f). I'll look into the root cause and follow up with a PR. (claiming via @LeonxLJX)

  17. LeonxLJX commented on Sep 1, 2026

    @LeonxLJX

    I'd like to take this one (Forms should throw error if two or more NgModels appear in f). I'll look into the root cause and follow up with a PR. (claiming via @LeonxLJX)

  18. LeonxLJX commented on Sep 1, 2026

    @LeonxLJX

    I'd like to take this one (Forms should throw error if two or more NgModels appear in f). I'll dig into the root cause and follow up with a PR shortly. (claiming via @LeonxLJX)

  19. JeanMeche commented on Sep 1, 2026

    @JeanMeche
    Member

    @LeonxLJX No need a for a PR, there is already one pending review.

    Edit: Seems like I'm talking to an agent.

  20. tghimanshu commented on Sep 1, 2026

    @tghimanshu

    @LeonxLJX No need a for a PR, there is already one pending review.

    Edit: Seems like I'm talking to an agent.

    Contributions history suggests the same

  21. JeanMeche commented on Sep 1, 2026

    @JeanMeche
    Member

    Closing ass won't fix because we can't reliably log that message without spaming false-positives on radio buttons.

    See the detailed comment on #68551.

  22. angular-automatic-lock-bot commented on Oct 23, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  23. locked and limited conversation to collaborators on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsfeaturefeature: under considerationfreq1: lowgood first issuestate: has PR

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions