Uploading images using Form Collections and Doctrine in Symfony2

前端 未结 1 859
轻奢々
轻奢々 2021-02-06 09:27

I have been trying to make a Form Collection with file upload in Symfony2 and following this guide

http://symfony.com/doc/master/cookbook/form/form_collections.html

1条回答
  •  孤街浪徒
    2021-02-06 10:16

    When you add by_reference => false you are suposed to set the counter entity in the add function.

    So your property_id should be persisting correctly in the image changing the addImage function in your propery to:

    public function addImage(\Mata\MainBundle\Entity\Image $image)
    {
      $this->images[] = $image;
    
      $image->setProperty($this);
    
      return $this;
    }
    

    0 讨论(0)
提交回复
热议问题