infinite-networks/InfiniteFormBundle — pull request #21 by dave-newson (2014-12-18 23:27:54+00:00)
Title: Entity property can be used as index for PolyCollection entries

We had a use case where we were using PolyCollection, but the data submitted by a JSON request would have certain items removed, and other items added. The order of the array could deviate, and the JSON data could not be changed to persist the length or keys of the array passed back to PolyCollection. This resulted in the PolyCollection form, the original list of items, and the submitted data becoming out of sync, and producing form errors.

This PR enables specifying an index_property, such as "id", rather than rely on the size/order of the PolyCollection array to infer the identity of submitted values, which is quite unreliable.
Where an index_property is provided for PolyCollection, data will be searched for and entities added/removed as required.

There is an additional change to the unit test testResizedDownIfBoundWithMissingDataAndAllowDeleteWithEntityIndexProperty to highlight that when using PolyCollection, the default identifier between items is simply the array key.