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

Error: More than one custom value accessor matches form control with unspecified name attribute #50

Closed
dgouissem opened this issue Nov 14, 2017 · 17 comments

Comments

@dgouissem
Copy link

dgouissem commented Nov 14, 2017

Hey,

I 'm using the Angular 5.0 and Angular Material 2.0.0-beta.8, when i applied the ngx-mask within my custom component i got the below error

 <md-input-container class="full-width">
  <input mdInput [mdDatepicker]="datepicker" placeholder="Date" mask="00/00/0000" dropSpecialCharacters="false" [placeholder]="label"
    [required]="required" [formControl]="formControl" />

  <md-datepicker #datepicker></md-datepicker>
  <span class="fa fa-calendar" mdPrefix>&nbsp;</span>
  <md-error *ngIf="error">{{ error }}</md-error>
</md-input-container>

ng:///FormComponentsModule/DateComponent.ngfactory.js:36 ERROR Error: More than one custom value accessor matches form control with unspecified name attribute
at _throwError (webpack-internal:///../../../forms/esm5/forms.js:2463)
at eval (webpack-internal:///../../../forms/esm5/forms.js:2544)
at Array.forEach ()
at selectValueAccessor (webpack-internal:///../../../forms/esm5/forms.js:2533)
at new FormControlDirective (webpack-internal:///../../../forms/esm5/forms.js:6463)
at createClass (webpack-internal:///../../../core/esm5/core.js:12363)
at createDirectiveInstance (webpack-internal:///../../../core/esm5/core.js:12206)
at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13644)
at callViewAction (webpack-internal:///../../../core/esm5/core.js:14076)
at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13985)

It seems that the formControl attribut is causing the issue when removing it any clue to resolve the issue

Thanks and regards

@NepipenkoIgor
Copy link
Collaborator

@dgouissem Thanks, we will check

@NepipenkoIgor
Copy link
Collaborator

@dgouissem We used ValueAccessor in our current realization, but angular have limitation -> we can use only one realization ValueAccessor. That why ngx-mask don't work with material.

@benj0c
Copy link

benj0c commented Aug 15, 2018

I have the same problem when try to use mask in combination with bsDatepicker.

<div class="form-group">
    <label class="control-label col-lg-2 text-right">Birthday</label>
    <div class="col-lg-4">
        <input type="text" class="form-control" formControlName="birthday" placeholder="MM/DD/YYYY"  mask="00/00/0000" autocomplete="off" bsDatepicker>
    </div>
</div>

@deividfortuna
Copy link

There is a workaround solution not using ngx-mask library
Take a look in this issue: angular/angular#16755

@aemonge
Copy link

aemonge commented Jun 13, 2019

Still the recommended option is not to use this library ?

@jongbonga
Copy link

still not fix here?

@muneebshafiq
Copy link

muneebshafiq commented Jan 21, 2020

[UPDATE]
I don't know where previous link was redirecting but correct link is here
ng-bootstrap/ng-bootstrap#2291 (comment)

Basically use Racoon mask instead of ngx-mask

@Markus-Ende
Copy link

@dgouissem We used ValueAccessor in our current realization, but angular have limitation -> we can use only one realization ValueAccessor. That why ngx-mask don't work with material.

Could you please add this as a big disclaimer in the documentation?

@rafaelgoncalves2010
Copy link

if it was to not work, why did you guys build it????????????!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!wtf

@Markus-Ende
Copy link

if it was to not work, why did you guys build it????????????!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!wtf

Please be respectful, this is open source work you don't have to use.

@ravenda900
Copy link

ravenda900 commented Feb 24, 2021

I manage to create a workaround that works perfectly based on my expectation. I created a hidden input that handles the datepicker, the mask itself is attached to the actual input that is visible and added a event listener dateSelect to set the value from the date picker to the actual input with mask.

EDIT: I also added the positionTarget input to make the datepicker look that its been initialized in the actual input

<div class="input-group">
  <input type="text" class="form-control" #startDateInput id="startDate" formControlName="startDate" [leadZeroDateTime]="true" mask="d0/M0/0000" />
  <input type="hidden" (dateSelect)="onDateSelect($event, 'startDate')" ngbDatepicker #start="ngbDatepicker" [positionTarget]="startDateInput">
  <button class="btn" (click)="start.toggle()" type="button">
  <i class="mdi mdi-calendar"></i>
  </button>
</div>
onDateSelect(date: NgbDate, key: string): void {
    const formControl: any = {};
    formControl[key] = this.dateAdapter.toModel(date);
    this.form.patchValue(formControl);
}

ezgif com-gif-maker

@toniellenk
Copy link

there's another way here too: ng-bootstrap/ng-bootstrap#2291 (comment).
use RacoonMask and NativeDateAdapter.

@marcosvmauri
Copy link

I manage to create a workaround that works perfectly based on my expectation. I created a hidden input that handles the datepicker, the mask itself is attached to the actual input that is visible and added a event listener dateSelect to set the value from the date picker to the actual input with mask.

EDIT: I also added the positionTarget input to make the datepicker look that its been initialized in the actual input

<div class="input-group">
  <input type="text" class="form-control" #startDateInput id="startDate" formControlName="startDate" [leadZeroDateTime]="true" mask="d0/M0/0000" />
  <input type="hidden" (dateSelect)="onDateSelect($event, 'startDate')" ngbDatepicker #start="ngbDatepicker" [positionTarget]="startDateInput">
  <button class="btn" (click)="start.toggle()" type="button">
  <i class="mdi mdi-calendar"></i>
  </button>
</div>
onDateSelect(date: NgbDate, key: string): void {
    const formControl: any = {};
    formControl[key] = this.dateAdapter.toModel(date);
    this.form.patchValue(formControl);
}

ezgif com-gif-maker

Please, can you help me.
I'm getting error Cannot find name 'DateAdapter'
When I implement this code

@gitalvininfo
Copy link

gitalvininfo commented Aug 5, 2021

Hi @NepipenkoIgor

May I ask if what is the status of this issue? I wish to implement a proper solution, not a workaround although it is working fine.
I am using ngbDatepicker of ng-bootstrap (Angular 11) and having this error in console

Error: More than one custom value accessor matches form control with unspecified name attribute.

Thank you.

@Leomhl
Copy link

Leomhl commented May 19, 2022

Same issue here :/

@mhagnumdw
Copy link

Has anyone found a simpler solution?

@ashkan-dev-86
Copy link

Has anyone found a simpler solution?

There is no simple solution

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

No branches or pull requests