Reputation: 55
I have this action:
/**
* @Route("/{id}", name="showpage", requirements={"id" : "\d+"})
*/
public function showAction(Car $car, Request $request)
{
// I have fetched $car
$form = $this->createForm(CarType::class, $car);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$driver = new Driver();
// Some logic...
$em = $this->getDoctrine()->getManager();
$em->persist($driver);
$em->flush();
//...
}
//..
}
I want only get info and form by $car
, but dont want update it.
How can I block flush()
for my $car
?
Upvotes: 3
Views: 1460
Reputation: 36989
You need to detach the entity. You can do that with
$em->detach($car);
Upvotes: 1