S
S
Sergey Nizhny Novgorod2018-08-21 18:35:20
symfony
Sergey Nizhny Novgorod, 2018-08-21 18:35:20

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;

3) I made this form:
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' => 'Создать статью'))
        ;
    }

4) And this is how I try to save:
$form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $article = $form->getData();

            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($article);
            $entityManager->flush();

            return $this->redirectToRoute("gate");
        }

As a result, there is an error
Neither the property "image" nor one of the methods "getImage()", "image()", "isImage()", "hasImage()", "__get()" exist and have public access in class "App\Entity\Article".
Although I don't have an image field, and I don't understand where it came from.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2018-08-21
@Terras

Used in the mimetype parameter in the @Vich\UploadableField annotation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question