-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
markAllAsDirty not doing anything #135
Comments
I figured out what's missing. The export function markAllDirty(control: AbstractControl): void {
// control is FormGroup with some nested FormControl
control.markAsDirty({ onlySelf: true });
// ok formGroup is markedAsDirty, nice.
// let's call the following for its nested FormControls
(control as any)._forEachChild((control: any) => {
// control.markAllAsDirty is undefined, no method call, no control.markAsDirty({ onlySelf: true });
control.markAllAsDirty?.();
});
// FormControl have no markAllAsDirty method... so will never be called for them
} This gets fixed by either adding a (control as any)._forEachChild((control: any) => control.markAllAsDirty?.() || control.markAsDirty({ onlySelf: true })); I'll submit a PR |
FormControl doesn't have a markAllAsDirty method Closes ngneat#135
Nice! thanks |
Is this a regression?
Yes
Description
Hello, a week ago, I migrated a project from angular 12 to angular 13. I bumped reactive-forms from
^1.7.5
to^4.0.2
(quite a huge bump...)All my forms use the same pattern when submitting
It seems that
markAllAsDirty
doesn't work as expected anymore. We had to replace this call with a custom functionand we now call
recursiveMarkAsDirty(this.form)
instead ofthis.form.markAllAsDirty()
when submitting.All forms are created like this
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in
Anything else?
No response
Do you want to create a pull request?
No
The text was updated successfully, but these errors were encountered: