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

Error when using single_upload #46

Closed
thibmonier opened this issue Aug 21, 2013 · 4 comments
Closed

Error when using single_upload #46

thibmonier opened this issue Aug 21, 2013 · 4 comments
Labels

Comments

@thibmonier
Copy link

I'm trying to use a single_upload, I follow instructions in documentation with VichUploader but I have this error when I'm doing a cache:clear or when I'm trying to display the list.

An exception has been thrown during the rendering of a template ("The dbType "virtual" is only for list implemented (column "articleImage" in "Acme\NewsBundle\Entity\Article")") in "Edit/FormBuilderTemplate.php.twig".

My config in generator.yml

    fields: 
        articleImage:
            label:            Image
            formType:         single_upload
            addFormOptions:
                nameable:       articleImageName
                deleteable:     articleImagePath
                data_class:     Symfony\Component\HttpFoundation\File\File

And my entity

/**
     * @Assert\File(
     *     maxSize="2M",
     *     mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
     * )
     * @Vich\UploadableField(mapping="article_image", fileNameProperty="articleImageName")
     * @var File $articleImage
     */
    protected $articleImage;

    /**
     * (Optional) holds file name
     *
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    protected $articleImageName;

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

Any ideas ?

@sescandell
Copy link
Member

Hi @thibmonier

Could you please show us your generator file?

Thank you,

@montabou
Copy link
Contributor

montabou commented Sep 4, 2013

And if you set dbType to string ?

@montabou
Copy link
Contributor

montabou commented Sep 4, 2013

like this:

    fields: 
        articleImage:
            label:            Image
            dbType:           string
            formType:         single_upload
            addFormOptions:
                nameable:       articleImageName
                deleteable:     articleImagePath
                data_class:     Symfony\Component\HttpFoundation\File\File

@thibmonier
Copy link
Author

finally I did this and it's working :

    fields:
        articleImage:
            label:            Image
            formType:         single_upload
            dbType:   string
            addFormOptions:
                nameable:       articleImageName
                deleteable:     articleImagePath
                data_class:     Symfony\Component\HttpFoundation\File\File
                previewFilter:  news_mini

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

3 participants