question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is no FormControl instance attached to form control element

See original GitHub issue

I have a formgroup with some formcontrols. On the view there is a selectbox, when the selection changing I call this angular method: this.tabForm.setControl(‘selectedHtmlControl’, control); -> where control is an AbstractControl instance.

After calling the above method I receive this error message:

Error: There is no FormControl instance attached to form control element with name: 'selectedHtmlControl' forms.js:2427 at _throwError (myProject\node_modules\@angular\forms\esm5\forms.js:2427:1) at _noControlError (myProject\node_modules\@angular\forms\esm5\forms.js:2409:1) at QuillComponent.eval [as onModelTouched] (myProject\node_modules\@angular\forms\esm5\forms.js:2324:58) at Emitter.eval (myProject\node_modules\ngx-quill\src\quill-editor.component.js:96:1) at Emitter.emit (myProject\node_modules\quill\dist\quill.js:8505:1) at Emitter.emit (myProject\node_modules\quill\dist\quill.js:1893:1) at Selection.update (myProject\node_modules\quill\dist\quill.js:3199:1) at eval (myProject\node_modules\quill\dist\quill.js:2871:1) at eval (myProject\node_modules\quill\dist\quill.js:1907:1) at Array.forEach (<anonymous>)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
KillerCodeMonkeycommented, Feb 6, 2018

@feco93 i added an example to the demo-repo.

seems like custom inputs/formcontrols with formControlName are only one-time-binded. so you need to use this:

<quill-editor [formControl]="form.controls['editor']"></quill-editor>

If you use setControl --> editor stores a new reference, but because it is only one-time-binded it does not get the new reference - it only loses the initial one. If you use the [formControl] it explicit creates a one-way-binding where it updates the reference on changes.

Hope this helps and fullfils your needs.

Please, close this issue if this is okay 😃

1reaction
KillerCodeMonkeycommented, Feb 6, 2018

okay but maybe we can achieve your goal with another approach:

You have correctly a FormArray with all your language dependent controls. Do not explicit store the current selected one.

simply store the index of the current active language --> and then:

<quill-editor [formControl]="form.controls['localizations'][activeLanguageIndex]"></quill-editor>

So you are not hacky overwrite existing ones, and you do not need another Control 😃

PS: I do not tested the code… so maybe you should use form.get(‘localizations’) and so on. it only should get you the idea how to solve your problem smart 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

There is no FormControl instance attached to form control ...
I solved this in this way: Before: formControlName="description". After: [formControl]="form.controls['description']".
Read more >
There is no FormControl instance attached to form control ...
Current behavior. When using ReactiveForms and we override old form group with the new one (using for example this.form = new FormGroup(.
Read more >
Form on input edit throws Error: There is no FormControl ...
Error: There is no FormControl instance attached to form control element with name: 'firstname' I console log my FormGroup object formGrp ...
Read more >
Angular reactive form for a filterable table is giving error ...
Angular reactive form for a filterable table is giving error "There is no FormControl instance attached". To try and provide somewhat of a ......
Read more >
Angular – There is no FormControl instance attached to form ...
There is no FormControl instance attached to form control element with name: controlName . The whole thing consists of 3 elements: 2 components ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found