components icon indicating copy to clipboard operation
components copied to clipboard

mat-select should provide itself as a ControlValueAccessor

Open Juraji opened this issue 8 years ago • 4 comments

Bug, feature request, or proposal:

Using a custom override of the FormControlDirective causes using [formControl] on mat-select to throw the following error:

ERROR Error: No value accessor for form control with unspecified name attribute
    at _throwError (forms.js?ec33:2415)
    at setUpControl (forms.js?ec33:2285)
    at FormControlDirective.ngOnChanges (forms.js?ec33:6448)
    ...

(The field will still work)

What is the expected behavior?

Being able to use a custom FormControlDirective implementation.

What is the current behavior?

An error is thrown by NgControl not being able to infer a ControlValueAccessor

What are the steps to reproduce?

Override Angular's core FormControlDirective and use it on a mat-select See the following plunk: http://plnkr.co/edit/x1ZO9mMv8zYZh9uescPo

What is the use-case or motivation for changing an existing behavior?

Using mat-select with a custom FormControlDirective. (for instance mat-slide-toggle does this correctly)

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

At least the following: Angular: 5.1.1 Material: 5.0.2 TypeScript: 2.6.2 Browsers: Chrome, Opera and Firefox OS: Windows, Mac, Linux

Is there anything else we should know?

Juraji avatar Jan 16 '18 20:01 Juraji

This has come up in the past. We can't do it for the select, because it needs to inject the NgControl which refers to itself and causes a circular import.

crisbeto avatar Jan 20 '18 15:01 crisbeto

@crisbeto as I noticed a bit too late... Sorry for wasting your time.

Juraji avatar Jan 25 '18 21:01 Juraji

is there a work around for this?? or does mat-select just not work with forms? @crisbeto @Juraji

JBoothUA avatar Oct 17 '18 18:10 JBoothUA

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.