-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The file upload is not picked up, if the file is the only field that has changed #123
Comments
I had the exact same problem today and solved it with a pretty nasty workaround. I have a field
This way it will always update your image field. Indeed this is not the solution I was looking for, but a pretty painless one after all. |
I ended up with something similar, I modified the setPictureFile() method on my entity: public function setPictureFile($pictureFile) {
$this->pictureFile = $pictureFile;
if ($pictureFile) {
$this->picture = $pictureFile->getFileName();
}
} The pictureFile attribute is the one with the uploader annotation. This seems somewhat safe, since it will be overwritten at flush time by the uploader. |
lost some time today to understand why the file upload don't work anymore. We should add something about this "issue" in the doc. |
Duplicated by #8 |
Hi everyone. I'm new at symfony. |
@hediyedel You should read the doc and then come back with a more specific question. If something is not clear in the doc let us know. |
@ftassi I've read it and done all changes, but when I copy |
Double check you annotation on the Entity class and open a dedicated issue for your problem, this one is not related to it. |
is there no any solution yet? |
Hi, i'm testing your bundle and when i save my Image entity the file is lost. My conf is like the exemple. Is it possible that my event listener is not call? even if my updatedAt is update in my database? |
@DavidM974 Can you open a new issue for your problem? Giving us your configuration would be nice too :) |
Thanks for your quick answer my bad! Now it works! |
If you have a user model, that has 4 attributes:
Id, name, and picturePath are persisted through Doctrine, the picture attribute is the one with the @Vich/UploadableField annotation, and has "picturePath" as its fileNameProperty attribute.
Create a form for this entity, then upload a new file, and modify nothing else on the form. The change will not be picked up. This is because the UploaderListener is listening on the prePersist and preUpdate events, which are never fired, since the only field that is modified by the form is the "picture" field, which is not mapped by Doctrine.
The text was updated successfully, but these errors were encountered: