Feature Request: A way to remove errors without rolling back
See original GitHub issueIn our form component and app we have a concept of non_field_errors which get returned from the api (default django-rest-framework behavior). These errors are “form-level” and not tied to a specific field.
To keep things simple we use our changeset form to display these if they occur by doing something like:
try {
yield bankcard.save();
} catch (err) {
err.errors.forEach(({ attribute, message }) => {
changeset.pushErrors(attribute, message[0]);
});
return undefined;
}
which if err === non_field_errors, our form template will render at the top of the form like:
{{cool-form/error changeset "non_field_errors"}}
The problem is if a user submits and receives a non_field_error, we have to then handle clearing just that one specific error before they can submit again. While this is easy to do, to delete just that specific error with no related input attached we have to do delete changeset._errors.non_field_errors
Proposal: Can we add a public interface to remove a single error without relying on private properties?
e.g. changeset.removeError('non_field_errors') or changeset.clearError('non_field_errors')
OR just a public way to clear all errors e.g. changeset.clearErrors() without rolling the form back
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:14 (1 by maintainers)

Top Related StackOverflow Question
I’ll try to get this one done this week…
Thanks for the detailed writeup @erichonkanen, this sounds reasonable to me.
My only concern is that I don’t remember (off the top of my head) if
changesanderrorsare mutually exclusive. Here’s what I mean:If
changesanderrorsare mutually exclusive, then feel free to open a PR for this! Maybe something likechangeset.rollback({ onlyErrors: true });?