StofDoctrineExtensionsBundle
StofDoctrineExtensionsBundle copied to clipboard
Uploadable sets value to null if no image is selected
I am having an issue with Uploadable. I have added an avatar property to my user. If the user updates his profile but does not change their avatar the column in the database gets set to null.
I noticed in the docs it said to add this to the form builder: ->add('avatar')
This was rendering a text input and not a file input.
I had to use this to get the file input: ->add('avatar', 'file', array('required' => false, 'data_class' => null))
I am guessing something might not be configured correctly, The upload does seem to work when actually trying to update the avatar however.
I have the following in my config.yml:
doctrine:
orm:
auto_mapping: true
.....
stof_doctrine_extensions:
orm:
default:
uploadable: true
I encounter the same issue here when updating my previously added entity.. The "file" form type should not trigger the update of the entity but indeed it's updated and the path is set to NULL into the database.. I still found no solution, tried many things with no success.
Any help?
@cazzoo @shawn-northrop did you find solution, guys? I am fighting the same battle now :smile:
No I'm not, I did a workaround that allow me single file to upload through a collection manager (UI)
Well, without seeing your class and what happens in setAvatar, I cannot help you