Embedding a collection of forms Symfony2 forms with adding and deleting allowed

后端 未结 3 1098
自闭症患者
自闭症患者 2021-02-06 02:31

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

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-06 03:05

    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.

    /**
     * @ORM\OneToMany(targetEntity="EntityClass", mappedBy="EntityVariable", indexBy="id")
     */
    private $collection;
    

提交回复
热议问题