I am reading for a while about this but found nothing that works for me. This is entity
/**
* @ORM\Column(type="string")
*
* @Assert\NotBlank(message="Molimo unesite PDF ili Word fajl.")
* @Assert\File(mimeTypes={ "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.ms-powerpoint", "application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"})
*/
private $body;
This is form
// Problem with empty field on edit persist! Form expect FileType but db sends string!!!
->add('body', FileType::class, [
//'data_class' => null,// <-- If I change it nothing happened.
'label' => 'Word ili pdf dokument',
'invalid_message' =>'Id posta nije validan',
'attr' => [
'class' => 'form-group',
]])
Everything is very simple and made following docs. I have entity that contains few properties one of them for files ($body). Files are set to be saved in web/uploads/post/ . When I go to edit page 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 by setting the "data_class" option to null or by adding a view transformer that transforms a string to an instance of Symfony\Component\HttpFoundation\File\File".
If i set data_status => null field is empty.
What I need is some link to example with this working, Data Transformer maybe?