Problem with the cancellation of changes in the case of simultaneous editing of a main and a linked entity
I have a problem relating to the cancellation of entity changes. Lets assume that we have two entities. A customer (entity A) and an order (entity B). A user creates a new object in entity A, edits it in a form. When creating, he can immediately add a new object from entity B (relationship 1:*), which is a sub object, and try to edit it in the open page. However, if the user gives up on editing entity B and closes the page or uses the cancel button, which both call "Cancel changes", and at the same time does not commit entity A before this operation, then the changes are cancelled for both entity B (this one is simply deleted) and entity A (if it has not been committed once before opening the form to edit entity B then it is also deleted). And I note there is no option set in the association to delete the second object if the first one is not deleted. I had an idea that I could do a simple trick: if the user presses "Cancel" then in nanoflow I perform a rollback on that object and if after this operation the main field is empty, it means that the entity B object can be deleted because it has not been edited yet. The snag is that I know this because the "main field" is verified on save (it has to be longer than 5). So I can't delete because my nanoflow will be blocked by the validation of this field - unless the user fills in this field first (for these minium 5 characters) and only then decides to cancel it, then it works :) But after all, I can't give a message: "if you want to cancel the creation of this object enter a minimum of 5 characters in the field or else I won't let you go". :D At the moment I have two options: - forcefully commit object A before trying to create object B hoping that the user doesn't opt out of saving A ;) - quit validating the fields in object B. Both of these options are problematic for many different reasons. But logically it should just be possible to cancel. Do you have any ideas on how to make it make more sense?