sonata-project/SonataAdminBundle — pull request #702 by pulse00 (2012-04-21 17:59:38+00:00)
Title: MergeCollectionListener fix

This PR adresses a problem for oneToMany relations in Symfony 2.1.

## Problem

When the `onBindNormData` method gets the `collection` data from the form and the `data` from the event, both return the same object. As a result, the entity is removed from the `$collection` instead of `$data` in line 50, when `->collectionRemoveElement($data, $entity)` is called.

## Solution

I've added a simple check for the equality of the `spl_object_hash`. If both collections are the same reference, the original collection is set as the data in the event.

I'm not 100% sure if this is a proper fix, because i don't really know the rationale behind the remove / add element logic in the Listener.

All i can say is that the rest of the admin forms in our app work as expected.