Answer the question
In order to leave comments, you need to log in
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)
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
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 questionAsk a Question
731 491 924 answers to any question