You must use the merge operation for objects in the disconnected state, and you want to put them in a managed state.
The merger should be performed as follows $entity = $em->merge($detachedEntity). It then $entityrefers to the fully managed copy returned by the merge operation. Therefore, if your $formcontains individual elements, you should configure your code as follows:
$doctrineManager = $this->getDoctrine()->getManager();
foreach ($form->getData()->getEntities() as $detachedEntity) {
$entity = $doctrineManager->merge($detachedEntity);
$doctrineManager->remove($entity);
}
$doctrineManager->flush();
, $form , , :
$doctrineManager = $this->getDoctrine()->getManager();
foreach ($form->getData()->getEntities() as $entity) {
$doctrineManager->remove($entity);
}
$doctrineManager->flush();
. Java Persistence API, Doctrine2 .

user3577953