Add update to reset value along with _pristineValue#432
Conversation
|
This looks fine, but I'm hesitant to expose new methods. What's the use case here? Any reason |
|
On many of my pages I'm including multiple forms on a component and have an 'Apply' button on the parent component for submitting changes. The user can make additional changes to the form inputs and click apply multiple times. I am calling my updateModel method after my the changes have been applied. There is also a 'Cancel' button on my page to allow the user to revert changes since the last apply, which I handle by calling resetForm. I was having issues before in cases where a user would apply changes, then set the field back to the original values and try to click apply, because I have logic trying to determine if the form has changed from its pristine state, because the _pristineValue and the new current value were the same. We also try to keep track of any unsaved changes on the page and bring up a dialog if the user tries to navigate away before hitting 'Apply'. The same logic for determining if the form is Changed compares the currentValues against the _pristineValue. So, if a user edits a form, then edits it back to its pristine value, I want them to be able to navigate away without getting the dialog. Additionally, there were issues where if the user made changes, then clicked apply any number of times, and then wanted to cancel changes, I didn't want to have to keep a state of the most recent applied settings to resetForm to. |
|
We definitely have similar use cases that this PR solves. |
Develop to master
…onChange callback
I'm wanting the ability to update the form inputs to a set of values and update the pristine value along with this too.