Skip to content
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

Using formControlName with material-datepicker gives No value accessor for form control #80

Open
Jagpreet16 opened this issue Feb 25, 2017 · 3 comments

Comments

@Jagpreet16
Copy link

Jagpreet16 commented Feb 25, 2017

Please help me on below. I am using material-datepicker with reactive forms.

I am getting the following error when the form loads.

Error: No value accessor for form control with name: 'birthday'
at _throwError (shared.js:122) [angular]
at setUpControl (shared.js:35) [angular]
at FormGroupDirective.addControl (form_group_directive.js:124) [angular]
at FormControlName._setUpControl (form_control_name.js:193) [angular]
at FormControlName.ngOnChanges (form_control_name.js:111) [angular]

@ChristopherLaytonWasTakenSoIWentWithT

This is due to the fact the library doesn't use the ControlValueAccessor. I plan on forking and updating this as it seems development for this repo may be dead.

What you can do is wrap it with a component that implments ControlValueAccessor to have it work properly with NgModel and all the Angular/Form stuff.

https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html

This post has a really detailed example of what needs to be done.

Hope all is well,
C Layton

@ChristopherLaytonWasTakenSoIWentWithT

#105 is a PR made to solve this... Though maybe we all should just fork and solve this ourselves

@alanent
Copy link

alanent commented Jun 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants