-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[FormField] Class does not reset properly with submit buttons #8848
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
Comments
You need to use resetForm() of the FormGroupDirective. |
I have access to the FormGroup. How would I get access to the FormGroupDirective? |
One of the ways can be seen in @willshowell's answer over here (I like this way): #4190 (comment) Or you can also use: <form #f="ngForm" (ngSumbit)="doAnything(f)">
</form> and in typescript: doAnything(f: FormGroupDirective) {
} |
Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Uh oh!
There was an error while loading. Please reload this page.
Bug, feature request, or proposal:
Bug
What is the expected behavior?
The mat-form-field-invalid class should be removed when calling myFormGroup.reset(), since this class normally only appears when the form control is invalid and touched. This does occur if I use a button of type="button" and not type="submit".
What is the current behavior?
The mat-form-field-invalid class does not reset properly after calling myFormGroup.reset() after a submit button is triggered.
What are the steps to reproduce?
http://plnkr.co/edit/QGtqH8DDylViivcny1BA?p=preview
Steps to reproduce:
Scenario 1
Scenario 2
Also note the value of mat-form-field-invalid in both scenarios.
What is the use-case or motivation for changing an existing behavior?
It is often common to reuse a form when entering multiple items into a system.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Tested using Angular 5.0.0, Material 5.0.0-rc.2, TypeScript 2.4.2
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: