Closed charleskessler closed 4 years ago
@charleskessler thanks for contacting us.
You are looking for undo functionality I think, and we don't have support for it out of the box. This is something you would need to build yourself.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
EditForm automatically updates the bound object which works great when creating a brand new model instance -- nice and tidy, and very efficient.
However, things get sticky when using EditForm to edit existing model instances.
If I want to give the user the option to back-out of the edit mode -- click Cancel for instance -- I have to implement my component as such:
Where I store a temp copy of the model (line 21 -- generated by MemberwiseClone), and when the Cancel button is clicked I restore the values of the original model using the temp copy (line 25-30)
This works well enough, but when dealing with dozens of models each with dozens of fields it gets to be a bit of a mess. I know I can use a library such as AutoMapper to make that task much easier, but it still feels very hacky to me.
Is there a more elegant solution to this problem?