Bug EA 3
For editing images in my Controller class MediaProfilCrudController extends AbstractCrudController
public function configureFields(string $pageName): iterable
{
yield IntegerField::new('id', 'ID')->onlyOnIndex();
yield ImageField::new('picture')
->setBasePath('assets/img/picture/');
}
I get this error :
The form's view data is expected to be a "Symfony\Component\HttpFoundation\File\File", but it is a "string". You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms "string" to an instance of "Symfony\Component\HttpFoundation\File\File".
I used it this way and its working
$avatar = ImageField::new('avatar')->setBasePath('uploads/images/users')->setLabel('Photo');
$avatarFile = ImageField::new('avatarFile')->setFormType(VichImageType::class);
if (Crud::PAGE_INDEX === $pageName) {
return [ $avatar];
} elseif (Crud::PAGE_EDIT=== $pageName) {
return [$avatarFile];
Thanks @Merazsohel i try
yield ImageField::new('pictureFile')->setFormType(VichImageType::class)->setLabel('Picture');
its working
I think this issue can be closed now.
@seb-jean sure
Can you close this issue?
@seb-jean No. I can't close this issue because of i have no permission. This issue opened by others.
@javiereguiluz can you please close this issue?
Most helpful comment
I used it this way and its working