I think you should use the clone
keyword to get a independent instance of the object you want to store. It should works by following these steps:
- Load the original entity (
$object
) - Clone the original entity to get a new temporary entity (
$newObject
) - Alter the
$newObject
to make it a new entry:$newObject->setId(null);
- Bind
$newObject
to the form - Save (persist)
$newObject
as a revision - Add the revision to (
$object
) and persist it too
I hope that if the form is invalid you won't lose all the data sent by the user.
Just in case, I used this answer to find the differences between the original entity and the one modified by the form.