StofDoctrineExtensionsBundle icon indicating copy to clipboard operation
StofDoctrineExtensionsBundle copied to clipboard

Uploadable sets value to null if no image is selected

Open electricBonfire opened this issue 11 years ago • 4 comments

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

electricBonfire avatar Nov 27 '13 23:11 electricBonfire

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 avatar Aug 09 '15 06:08 cazzoo

@cazzoo @shawn-northrop did you find solution, guys? I am fighting the same battle now :smile:

charlie-wasp avatar Nov 05 '15 14:11 charlie-wasp

No I'm not, I did a workaround that allow me single file to upload through a collection manager (UI)

cazzoo avatar Nov 05 '15 15:11 cazzoo

Well, without seeing your class and what happens in setAvatar, I cannot help you

stof avatar Nov 05 '15 15:11 stof