I am trying to display some images in my bundle (using easyadmin bundle) & symfony 3.4 However, for some reason, the photos aren't showing. here's my code: in config.yml:
Employee:
class: BackofficeBundle\Entity\Employee
role_prefix: ROLE_EMPLOYEE_MANAGER
list:
fields:
- id
- Name
- { property: 'photo', label: 'EMPLOYEE AVATAR', type: 'image' , base_path: '/images/' }
in my Employee entity:
/**
* @ORM\Column(name="photo", type="string", length=500)
* @Assert\File(maxSize="500k", mimeTypes={"image/jpeg", "image/jpg", "image/png", "image/GIF"})
*/
private $photo;
in my EmployeeType.php
$builder->add('photo', FileType::class, array('data_class'=>null, 'required'=>false
));
The photo aren't showing in the List page and when i click on the edit i get this error :
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.
For this case, please consider using VichUploadBundle https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/vichuploaderbundle.html