My controller:
/**
* @Route("/row/{slug}/{connect}/{field}/{productgroup}", name="row", methods={"POST"})
*/
public function row($slug, $connect, $field,$productgroup, Request $request) {
$EntityName = 'App\\Entity\\' . ucwords($slug);
$con = 'App\\Entity\\' . ucwords($connect);
$entity = $this->getDoctrine()->getRepository($EntityName)->findOneBy(['id' => $field]);
$entityManager = $this->getDoctrine()->getManager();
$argsId = $productgroup;
$args = $entityManager->getReference($connect , $argsId);
$entity->setProductgroup($args);
$entityManager->flush();
$response = new Response();
$response->send();
return $response;
}
The error message:
Class 'Productgroup' does not exist