Skip to content
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

Help on basic configuration #92

Closed
artworkad opened this issue Jan 1, 2013 · 10 comments
Closed

Help on basic configuration #92

artworkad opened this issue Jan 1, 2013 · 10 comments
Labels

Comments

@artworkad
Copy link

Hi,

I am using sf 2.1. My config:

vich_uploader:
db_driver: orm
mappings:
gallery_image:
uri_prefix: /uploaded-images
upload_destination: %kernel.root_dir%/../web/uploaded-images

Entity definition: http://dpaste.com/859301/

Entity class: http://dpaste.com/859302/

Form Type: http://dpaste.com/859303/

Controller: http://dpaste.com/859304/

After form is posted I get following error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'image_name' cannot be null

So the bundle seems not to work for me. any ideas what might be wrong?

@gchokeen
Copy link

gchokeen commented Jan 5, 2013

@artworkad : when you getting this error, Doctrine will validate your imageName field. If you want to make this field optional add nullable=true to the annotation.

    /**
     * @ORM\Column(type="string", length=255, name="image_name", nullable=true)
     *
     * @var string $imageName
     */
    protected $imageName;

@artworkad
Copy link
Author

but no image is uploaded at all. so this seems not to be the problem?

@gchokeen
Copy link

gchokeen commented Jan 5, 2013

That's what I am saying. While don't upload any file. imageName field will be null, so doctrine won't allow to store other entity and throw the exception

Column 'image_name' cannot be null

if you add nullable=true. imageName field will become optional.

@artworkad
Copy link
Author

Iadded the nullable=true statement. Image is inserted in DB but no image is not uploaded.

@soerenmartius
Copy link

Did you solve it meanwhile? I have exact the same issue

@artworkad
Copy link
Author

No. For now I use http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html#using-lifecycle-callbacks However I guess the problem is that I mixed up xml mappings and annotation mappings.

@zabojad
Copy link

zabojad commented Jan 10, 2013

Damn, I've managed to make it work once and now it doesn't work anymore, same issue as yours... I may have updated with composer one of my bundles that broke this... If it's not because of that, then I don't what could be the cause...

What debug steps could we follow to know more about it ?

@gchokeen
Copy link

Once I had same issue (file not uploaded), latterly i recognized that used wrong name(imageName) in form builder. Then i replaced imageName instead of image issue was resolved.

@zabojad
Copy link

zabojad commented Jan 10, 2013

Actually, it works at my end, but not in all cases, See #96 (comment)

@K-Phoen K-Phoen closed this as completed May 16, 2014
@AnyFullStackApps
Copy link

gchokeen -> I wanna get the name of the file I'm trying to upload...not to escape and leave it empty....could you help to sort it out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants