vitiko / IphpFileStoreBundle

Symfony 2 file upload for doctrine entities
http://symfonydev.ru/iphpfilestorebundle/
51 stars 23 forks source link

Can't make it work #5

Closed getme closed 11 years ago

getme commented 11 years ago

Hi, can't make it work out of the box. Symfony2.1

/**
* @FileStore\Uploadable()
**/
class VehicleCat
{
   /**
     * @var string
     *
     * @ORM\Column(name="image", type="string", length=255, nullable=true)
     * @FileStore\UploadableField(mapping="vehicle_cat")
     */
    private $image;

}
$builder->add('image', 'file', array(
   'required' => false,
));

Throwing: The form's view data is expected to be an instance of class Symfony\Component\HttpFoundation\File\File, but is a(n) string. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) string to an instance of Symfony\Component\HttpFoundation\File\File.

$builder->add('image', 'file', array(
  'required' => false,
  'data_class' => null,
 ));

Throwing: Warning: Illegal string offset 'fileName' in /path/vendor/iphp/filestore-bundle/Iphp/FileStoreBundle/EventListener/UploaderListener.php line 162

vitiko commented 11 years ago

https://github.com/vitiko/IphpFileStoreBundle - add missed doctrine configuration example, field with file data must have type=array

getme commented 11 years ago

Works now, Thanks)