I am using the cookbook article from symfony.com to implement a file upload option for images.
Now I want to load up other images to the entity.
The default strategy for editing is: 1. Fetch out of DB 2. Inject into Form 3. Persist
Somehow this strategy doesn't work anymore when using file uploads (doctrine doesn't execute the events)
What else could I do to make the articles with picture editable?
The cookbook does not handle updates, in particular in the case where only the file changes.
In this case, the PreUpdate
event is not triggered, so you need to trigger $entity->preUpload()
manually before the $em->persist($entity)
, so that the file upload gets handled in any case (preUpload will alter $entity->path
so the persisting will occur)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With