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

Upload File error #775

Closed
rpostolov opened this issue Jul 30, 2014 · 3 comments
Closed

Upload File error #775

rpostolov opened this issue Jul 30, 2014 · 3 comments

Comments

@rpostolov
Copy link

Hi,

I use admingenerator for my backoffice and i use vich-uploader to upload files but after configuration i reload my page and i have this issue : Could not load type "single_upload"

I already looked at this #396 but i think its too old because links doesn't works.

Can someone help me please ?

Have a nice day !

here is my configuration :

I'm on Symfony 2.3

My class:

<?php

namespace Tranoi\SiteBundle\Entity;

use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Translatable;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\File;

/**
 * Pays
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Tranoi\SiteBundle\Entity\PaysRepository")
 * @Vich\Uploadable 
 */
class Pays implements Translatable
{    

    /**
     * @var ArrayCollection Designer $designers
     * @ORM\OneToMany(targetEntity="Tranoi\DesignerBundle\Entity\Designer", mappedBy="pays")
     */
    private $designers;

    /**
     * @var ArrayCollection Showroom $showrooms
     * @ORM\OneToMany(targetEntity="Tranoi\DesignerBundle\Entity\Showroom", mappedBy="pays")
     */
    private $showrooms;

    /**
     * @Gedmo\Locale
     * Used locale to override Translation listener`s locale
     * this is not a mapped field of entity metadata, just a simple property
     */
    private $locale;

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     * @Gedmo\Translatable
     * @ORM\Column(name="libelle", type="string", length=50, nullable=false)
     */
    private $libelle;

    /**
     * @var string
     * @ORM\Column(name="code_pays", type="string", length=50, nullable=false)
     */
    private $codePays;


    /**
     * @Vich\UploadableField(mapping="drapeau_image", fileNameProperty="drapeau")
     * @var File $drapeauFile
     */
    protected $drapeauFile;

    /**
     * @var string
     * @ORM\Column(name="drapeau", type="string", length=100, nullable=true)
     */
    private $drapeau;

    /**
     * @var string
     * @ORM\Column(name="indicatif_telephonique", type="string", length=10, nullable=false)
     */
    private $indicatifTelephonique;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set libelle
     *
     * @param string $libelle
     * @return Pays
     */
    public function setLibelle($libelle)
    {
        $this->libelle = $libelle;

        return $this;
    }

    /**
     * Get libelle
     *
     * @return string 
     */
    public function getLibelle()
    {
        return $this->libelle;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->designers = new \Doctrine\Common\Collections\ArrayCollection();
        $this->showrooms = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Set codePays
     *
     * @param string $codePays
     * @return Pays
     */
    public function setCodePays($codePays)
    {
        $this->codePays = $codePays;

        return $this;
    }

    /**
     * Get codePays
     *
     * @return string 
     */
    public function getCodePays()
    {
        return $this->codePays;
    }

    /**
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
     * must be able to accept an instance of 'File' as the bundle will inject one here
     * during Doctrine hydration.
     *
     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
     */
    public function setDrapeauFile(File $image)
    {
        $this->drapeauFile = $image;

        if ($image) {
            $this->updatedAt = new \DateTime('now');
        }
    }

    /**
     * @return File
     */
    public function getDrapeauFile()
    {
        return $this->drapeauFile;
    }

    /**
     * Set drapeau
     *
     * @param string $drapeau
     * @return Pays
     */
    public function setDrapeau($drapeau)
    {
        $this->drapeau = $drapeau;

        return $this;
    }

    /**
     * Get drapeau
     *
     * @return string 
     */
    public function getDrapeau()
    {
        return $this->drapeau;
    }

    /**
     * Set indicatifTelephonique
     *
     * @param string $indicatifTelephonique
     * @return Pays
     */
    public function setIndicatifTelephonique($indicatifTelephonique)
    {
        $this->indicatifTelephonique = $indicatifTelephonique;

        return $this;
    }

    /**
     * Get indicatifTelephonique
     *
     * @return string 
     */
    public function getIndicatifTelephonique()
    {
        return $this->indicatifTelephonique;
    }

    /**
     * Add designers
     *
     * @param \Tranoi\DesignerBundle\Entity\Designer $designers
     * @return Pays
     */
    public function addDesigner(\Tranoi\DesignerBundle\Entity\Designer $designers)
    {
        $this->designers[] = $designers;

        return $this;
    }

    /**
     * Remove designers
     *
     * @param \Tranoi\DesignerBundle\Entity\Designer $designers
     */
    public function removeDesigner(\Tranoi\DesignerBundle\Entity\Designer $designers)
    {
        $this->designers->removeElement($designers);
    }

    /**
     * Get designers
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getDesigners()
    {
        return $this->designers;
    }

    /**
     * Add showrooms
     *
     * @param \Tranoi\DesignerBundle\Entity\Showroom $showrooms
     * @return Pays
     */
    public function addShowroom(\Tranoi\DesignerBundle\Entity\Showroom $showrooms)
    {
        $this->showrooms[] = $showrooms;

        return $this;
    }

    /**
     * Remove showrooms
     *
     * @param \Tranoi\DesignerBundle\Entity\Showroom $showrooms
     */
    public function removeShowroom(\Tranoi\DesignerBundle\Entity\Showroom $showrooms)
    {
        $this->showrooms->removeElement($showrooms);
    }

    /**
     * Get showrooms
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getShowrooms()
    {
        return $this->showrooms;
    }

    public function __toString()
    {
        return $this->libelle;
    }

}

admin-generator.yml :

drapeauFile:
        label:            Flag
        formType:         single_upload
        dbType:           string
        addFormOptions:
           nameable:       drapeau
           data_class:     Symfony\Component\HttpFoundation\File\File 
           previewImages: true
           previewAsCanvas: true
           thumbnailFilter: drapeau200w200h   

app/config.yml

vich_uploader:
    db_driver: orm
    gaufrette: true
    twig: true
    storage: vich_uploader.storage.gaufrette

    mappings:  
        drapeau_image:
            uri_prefix: /images/drapeau
            upload_destination: drapeau_image_fs
            namer: vich_uploader.namer_uniqid
            delete_on_remove: true # determines whether to delete file upon removal of entity
            delete_on_update: true #
            inject_on_load: true # determines whether to inject a File instance upon load
@ioleo
Copy link
Member

ioleo commented Jul 30, 2014

Is AvocodeFormExtensionsBundle registered in your app/AppKernel.php?

@rpostolov
Copy link
Author

Hi Loostro and thank you very much for responding so quickly !

I was just reading about that, i have to use Avocode for single_upload now. I will install this and configure it and see if it will work.

Thank you again for your respons :)

@ioleo
Copy link
Member

ioleo commented Jul 30, 2014

@rpostolov the single_upload form type is part of "AvocodeFormExtensionsBundle" which is right now under Admingenerator github organization symfony2admingenerator/FormExtensions

We plan to rename the bundle soon, but for now it's still named AvocodeFormExtensionsBundle

@ioleo ioleo closed this as completed Jul 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants