W
W
wolverine7772019-04-09 16:03:37
symfony
wolverine777, 2019-04-09 16:03:37

Error EntityManager#remove() expects parameter 1 to be an entity object, array given. - how to fix?

Good afternoon, I'm new to symphony 4 - please help me figure out what's wrong.
I'm trying to delete a user from the intermediate table, this is what I have in twig:
(for some reason I can not display the twig code correctly, so the screenshot)
5cac9a0be9a0a844451769.jpeg
Next, in the controller I have this
/**
* @Route("/deletion", name= "deletion")
*/
public function delete() {
$deleteUser = $this->getDoctrine()->getRepository(EvaluationUser::class)->findBy($_POST);
dump($deleteUser); // die;
$em = $this->getDoctrine()->getManager();
$em->remove($deleteUser);
$em->flush();
As a result, if I dump-give $deleteUser - in the dump I have everything I need - both idUser and idEvaluation
When I try to put the final point (remove + flush) - an error ...
Many thanks for any ideas in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2019-04-09
@wolverine777

If you assume that one entity will come, then get the object correctly:
Otherwise, you get an array with one element

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question