Answer the question
In order to leave comments, you need to log in
VichUploaderBundle is asking for a field that isn't there?
1) I use VichUploaderBundle to upload files
2) I made two fields, one that stores the name and the second file locator
/**
* @ORM\Column(type="string", length=255)
*/
private $articleImage;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="article_image", fileNameProperty="articleImage", size="imageSize", mimeType="image.mimeType")
*
* @var File
*/
private $imageFile;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('articleTitle')
->add('articleBody')
->add('thumbNumber')
->add('seoDescription')
->add('imageFile', VichImageType::class, [
'required' => false,
'allow_delete' => true,
'download_label' => '...',
'download_uri' => true,
'image_uri' => true,
])
->add('save', SubmitType::class, array('label' => 'Создать статью'))
;
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$article = $form->getData();
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($article);
$entityManager->flush();
return $this->redirectToRoute("gate");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question