symfony2admingenerator / AvocodeFormExtensionsBundle

(old-legacy) Symfony2 form extensions for Admingenerator project (also working standalone!)
Other
48 stars 31 forks source link

Error when using single_upload #46

Closed thibmonier closed 11 years ago

thibmonier commented 11 years ago

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 commented 11 years ago

Hi @thibmonier

Could you please show us your generator file?

Thank you,

montabou commented 11 years ago

And if you set dbType to string ?

montabou commented 11 years ago

like this:

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

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