I'm using Symfony2.5 and Doctrine 2.4.2. I have two entities, PageImages which extends Page
Page:
/**
* @ORM\ManyToMany(targetEntity="PageImage",cascade={"persist"})
*/
private $images;
Using form collection to create add images to the Page entity
When i create a new entry for PageImage it works just fine, PrePersist,PreUpdate,PostPersist,PostUpdate all run,
But when I try to change the image for an existing PageImage the event doesn't fire and doesn't upload new images.
Update: It doesn’t updating because the $file field is just a virtual and doctrine doesn’t see new data, and events aren't fired, so the easiest solution to do:
public function setFile(UploadedFile $file = null)
{
$this->temp = $this->getPath();
$this->file = $file;
$this->preUpload();
}