Easyadmin 中的照片字段未显示
PHOTO FIELD IN EASYADMIN IS NOT SHOWING
我正在尝试在我的包中显示一些图像(使用 easyadmin 包)和 symfony 3.4
但是,由于某种原因,这些照片没有显示。
这是我的代码:
在 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/' }
在我的员工实体中:
/**
* @ORM\Column(name="photo", type="string", length=500)
* @Assert\File(maxSize="500k", mimeTypes={"image/jpeg", "image/jpg", "image/png", "image/GIF"})
*/
private $photo;
在我的 EmployeeType.php
$builder->add('photo', FileType::class, array('data_class'=>null, 'required'=>false
));
照片未显示在“列表”页面中,当我单击编辑时出现此错误:
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.
对于这种情况,请考虑使用VichUploadBundle https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/vichuploaderbundle.html
我正在尝试在我的包中显示一些图像(使用 easyadmin 包)和 symfony 3.4 但是,由于某种原因,这些照片没有显示。 这是我的代码: 在 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/' }
在我的员工实体中:
/**
* @ORM\Column(name="photo", type="string", length=500)
* @Assert\File(maxSize="500k", mimeTypes={"image/jpeg", "image/jpg", "image/png", "image/GIF"})
*/
private $photo;
在我的 EmployeeType.php
$builder->add('photo', FileType::class, array('data_class'=>null, 'required'=>false
));
照片未显示在“列表”页面中,当我单击编辑时出现此错误:
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.
对于这种情况,请考虑使用VichUploadBundle https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/vichuploaderbundle.html