Skip to content

Improve error message "No value accessor for form control with unspecified name attribute" to suggest what to do to fix the issue #43821

@zlepper

Description

@zlepper

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 a NG_VALUE_ACCESSOR. In this case you need to use ngDefaultControl on the element.

Alternatively you have forgotten to register a NG_VALUE_ACCESSOR for your custom form input:

providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef(() => MyInputField),
      multi: true
    }
  ]
  

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.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: formshotlist: error messagestype: bug/fix

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions