-
-
Notifications
You must be signed in to change notification settings - Fork 140
Feature Request: A way to remove errors without rolling back #282
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
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 const c = new Changeset(...);
c.set('phoneNumber', '123-123-1234'); // valid, internal changes map has 'phoneNumber'
c.set('phoneNumber', 'asdfhjkl'); // invalid, internal errors map has 'phoneNumber'
// but does the internal changes map still have 'phoneNumber'? If |
I'll try to get this one done this week... |
@erichonkanen Does either of these two https://github.com/poteto/ember-changeset#rollbackinvalid |
@snewcomer hey thanks for the update, the use case is to clear an error but don't roll back the form. |
@snewcomer I hadn't seen those before, let me try those out and get back to you.. but basically we handle form-level errors in our changeset form by doing |
@erichonkanen Yeah it seems like |
@erichonkanen - Were you doing a notifyProperty or something else on changeset to get isValid to recompute? I did a removeObject on the error I manually pushed in (leaving an empty array), but changeset.isValid still resolves false. (usving v1.4.2) |
@hornetnz If you don't mind, try 2.0 and lmk if that fixes the issues you are seeing. Otherwise, definitely open to a PR! |
@hornetnz I think I actually had to do something like |
Ok, thanks for the reply @erichonkanen! I'm unable to upgrade currently because we have some monkey-patches in this changeset to work with our unique data structure. |
@hornetnz or @erichonkanen is there an opportunity to extend ember-changeset to enable some of these features? Do you mind sharing those monkey patches? Looking at improving the internals. |
@snewcomer I think in the latest version it's no longer necessary since rollbackProperty was added |
Cool. Sry what do you mean...
Is everything fixed for you? |
yeah, the monkey patch I was referencing was for 1.3, no longer necessary |
In 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:
which if
err
===non_field_errors
, our form template will render at the top of the form like: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')
orchangeset.clearError('non_field_errors')
OR just a public way to clear all errors e.g.
changeset.clearErrors()
without rolling the form backThe text was updated successfully, but these errors were encountered: