In Symfony2, if I embed a collection of forms pointing at a many to one relationship in Doctrine and allow adding and deletion, if I delete a record from the beginning, add one
If you want to index the collection (by the entity id) for all querys, you can simply use the indexBy annotation in your entity class.
indexBy
/** * @ORM\OneToMany(targetEntity="EntityClass", mappedBy="EntityVariable", indexBy="id") */ private $collection;