IphpFileStoreBundle icon indicating copy to clipboard operation
IphpFileStoreBundle copied to clipboard

Cannot use FileType because the name is already in use

Open rifats opened this issue 9 years ago • 3 comments

Hello! After bundle update I have the error in SonataAdmin: Compile Error: Cannot use Symfony\Component\Form\Extension\Core\Type\FileType as FileType because the name is already in use. ... in vendor\iphp\filestore-bundle\Iphp\FileStoreBundle\Form\Type\FileTypeBindSubscriber.php at line 8

And second... Now we have three properties for use:

    /**
     * @ORM\Column(type="array")
     * @Assert\Image( maxSize="20M")
     * @FileStore\UploadableField(mapping="photo")
     **/
    private $photo;
    /**
     * Only for upload
     * @Assert\Image( maxSize="20M")
     * @FileStore\UploadableField(mapping="photo", fileDataProperty="photoInfo")
     **/
    private $photoUpload;
    /**
     * Only for store file info in db
     * @ORM\Column(type="array")
     **/
    private $photoInfo;

Is it right?

rifats avatar Oct 03 '16 23:10 rifats

  1. can't reproduce this error, please try dev-master, i remove use ...FileType from FileTypeBindSubscriber.php in commit fd6fd1658f4524f9ca0a05e191cbc5648fcbc935
  2. No, we have 2 mutually exclusive options:
  • one field for upload and storing file data ($photo in example above)
  • first field for upload ($photoUpload) and second field ($photoInfo) for store file info

second option appeared, because use one field for file upload and data storage leads to a possible validation errors

vitiko avatar Oct 05 '16 08:10 vitiko

Спасибо!

  1. В dev-master ошибка не возникает.
  2. То есть можно использовать либо прежний вариант с одним полем $photo, либо новый с двумя $photoUpload и $photoInfo ($photo)? Чтобы перейти от старого к новому достаточно изменить аннотацию свойства $photo (оставить только @ORM) и добавить свойство $photoUpload?

rifats avatar Oct 05 '16 20:10 rifats

This is not working form me. I'm following the documentation. As far as I know, no field can be photo in the Admin class.

$formMapper->add('title')
                         ->add ('date')
                         ->add('photo', IphpFileType::class);

For field in the Entity class is private $photoInfo; I try this but it's not working. Only the fields label shows, with no button to upload an image. Help would be highly appreciated.

sunviwo avatar Dec 29 '16 12:12 sunviwo