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

🐞 - Accordion throws error if [tuiAccordionItemContent] includes FormGroup #8160

Open
2 of 9 tasks
nsbarsukov opened this issue Jul 19, 2024 · 0 comments
Open
2 of 9 tasks
Labels
bug Something isn't working state: need triage

Comments

@nsbarsukov
Copy link
Member

Playground Link

https://stackblitz.com/edit/accordion-form-control-error?file=src%2Fapp%2Fapp.template.html

Description

<!-- No error βœ… -->
<form [formGroup]="testForm">
  <tui-input formControlName="name"></tui-input>
</form>
<tui-accordion>
  <tui-accordion-item>
    Click me to see error

    <ng-template tuiAccordionItemContent>
      <form [formGroup]="testForm">
        <!-- It throws error on click ❌ -->
        <tui-input formControlName="name"></tui-input>
      </form>
    </ng-template>
  </tui-accordion-item>
</tui-accordion>

Error logs:

ERROR Error: NG01350: 
    ngModel cannot be used to register form controls with a parent formGroup directive.  Try using
    formGroup's partner directive "formControlName" instead.  Example:

    
  <div [formGroup]="myGroup">
    <input formControlName="firstName">
  </div>

  In your class:

  this.myGroup = new FormGroup({
      firstName: new FormControl()
  });

    Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:

    Example:

    
  <div [formGroup]="myGroup">
      <input formControlName="firstName">
      <input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}">
  </div>

    at modelParentException (ng_model_group.ts:35:1)
    at NgModel._checkParentType (ng_model.ts:242:14)
    at NgModel._checkForErrors (ng_model.ts:240:14)
    at NgModel.ngOnChanges (ng_model.ts:342:9)
    at NgModel.rememberChangeHistoryAndInvokeOnChangesHook (ng_onchanges_feature.ts:74:12)
    at callHookInternal (hooks.ts:289:7)
    at callHook (hooks.ts:321:4)
    at callHooks (hooks.ts:269:11)
    at executeInitAndCheckHooks (hooks.ts:204:7)
    at selectIndexInternal (write_to_directive_input.ts:49:6)

Angular version

16 & 18

Taiga UI version

4.0.0-rc.6

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android
@nsbarsukov nsbarsukov added bug Something isn't working state: need triage labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working state: need triage
Development

No branches or pull requests

1 participant