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
FieldArrayType this.remove(index) without triggering form to be dirty #2044
Labels
Comments
adding an extra option that allows skipping @Component({
selector: 'formly-repeat-section',
template: `
...
<button type="button"
(click)="remove(i, { markAsDirsty: false })">
Remove
</button>
`,
})
export class RepeatTypeComponent extends FieldArrayType {
...
remove(i: number, { markAsDirsty } = { markAsDirsty: true }) {
const isDirty = this.formControl.dirty;
super.remove(i);
if (!isDirty && markAsDirsty === false) {
this.formControl.markAsPristine();
}
}
} |
aitboudad
added a commit
that referenced
this issue
Feb 10, 2020
aitboudad
added a commit
that referenced
this issue
Feb 12, 2020
aitboudad
added a commit
that referenced
this issue
Feb 20, 2020
aitboudad
added a commit
that referenced
this issue
Mar 6, 2020
aitboudad
added a commit
that referenced
this issue
Mar 14, 2020
aitboudad
added a commit
that referenced
this issue
Mar 17, 2020
fix #2044 # Conflicts: # src/core/src/lib/templates/field-array.type.spec.ts
aitboudad
added a commit
that referenced
this issue
Mar 17, 2020
fix #2044 # Conflicts: # src/core/src/lib/templates/field-array.type.spec.ts
This issue has been fixed and released as part of v5.6.0 release. Please let us know, in case you are still encountering a similar issue/problem. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Question
Hi,
I have a scenario where I want to remove a form/field from my fieldArray, but i don't want this to be triggered as dirty as I perform my operations in piece-meal, meaning i don't have an overall "save" button to reset my form to pristine, once i press the delete button it will call an async request as well as calling this.remove(index);
I'm curious is there a way to call this.remove(index) without causing my form to be dirty?
use case:
I have an unsaved warning message when a user triggers the form to be dirty when navigating away, however i don't want this to be displayed when deleting a form/field.
The text was updated successfully, but these errors were encountered: