New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message "No value accessor for form control with unspecified name attribute" to suggest what to do to fix the issue #43821
Comments
It can also happen when you forgot to import the component's module. I think the error message should be improved for clarity. |
Thanks a ton ! |
Hi, In my case this happens:
The error message does not help me and is very confusing because I do not use form tag in this context. |
I just ran into this error occurring as output for a failing test. The solution was to add the missing custom form component to the Testbed.configureTestingModule component declarations for the component I'm trying to test and the error went away. Noting this here as another scenario where this error can be seen and not understood. |
I came across this error under fairly specific circumstances while migrating an angular project to Nx with Module Federation. Just in case anyone comes across this issue with a similar situation. I have a shared library that declares a custom control with the Worked fine at first but when I declared in the webpack.config.js that the shared library should actually be shared and not be included twice the controls broke with the mentioned very unhelpful error message: sharedMappings.register(tsConfigPath, ['@myapp/shared', ...])
// ^-- added shared lib to the sharedMappings declaration
// of '@angular-architects/module-federation' In my case, the root cause of this error was that I did not share the module.exports = {
...
plugins: [
new ModuleFederationPlugin({
remotes: {
...
},
shared: share({
'@angular/forms': { // <-- This was missing
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
includeSecondaries: true
},
...
}),
...
}),
...
]
}; I know this is very specific, but still, the error message did not lead me anywhere useful :) |
Thanks for this. This was exactly the problem I had :) |
just adding my issue and resolution (add ngDefaultControl): This works in another project (angular 12.2.3) but not in this 13.3.0. (not sure if it has to do with that... the code, works with ngDefaultControl but not without it,
|
Thank you so much !!, You just saved me hours of debugging, I had the exact same error.
|
Minimal reproduction: https://stackblitz.com/edit/angular-ivy-3lbs6q?file=src%2Fapp%2Fapp.component.ts |
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
Thank you to everyone who commented, @zlepper @KurtGokhan @lufo88ita @mikebellcoder @LoaderB0T. I have opened #47969 to link this error message to a guide with debugging suggestions. (Feel free to comment on the PR or edit the guide if you come up with other cases or want to improve it further.) The error code and guide will begin showing up in v15.0.1. |
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
…guide. [A Github issue](angular#43821) about an arcane-sounding Forms error is one of the repo's top-ten most visited pages. This converts the error to `RuntimeErrorCode` and adds a dedicated guide to explain how to solve it.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are relevant/releated to the feature request?
forms
Description
When you get the error
No value accessor for form control with unspecified name attribute
, there are generally two things that possibly has gone wrong:You are using
ngModel
with a third party control that doesn't register aNG_VALUE_ACCESSOR
. In this case you need to usengDefaultControl
on the element.Alternatively you have forgotten to register a
NG_VALUE_ACCESSOR
for your custom form input:Proposed solution
It would be very nice if the error message Angular generated would actually suggest on of those things as being the actually problem, and thus what you should probably do to fix it, in the error message.
Alternatives considered
I mean, Angular could just leave it as is, and people can keep using Google I guess, though that is a suboptimal solution in my opinion.
The text was updated successfully, but these errors were encountered: