1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
public function modifierAction($id)
{
$repository = $this->getDoctrine()->getManager()->getRepository('Bundle:ConfBriques');
$brique = $repository->find($id);
$form = $this->createForm(new ConfBriquesType, $brique, array('id' => $brique->getId()));
$request = $this->get('request');
if($request->getMethod() == 'POST')
{
$form->bind($request);
if($form->isValid())
{
//Le foreach me permet d'ajouter la selection mais je trouve ça pas logique ...
foreach($brique->getApplications()->toArray() as $application)
$brique->addApplication($application);
$em = $this->getDoctrine()->getEntityManager();
$em->persist($brique);
$em->flush();
return $this->redirect($this->generateUrl('meteo_applis_admin_briques'));
}
}
return $this->render('MeteoApplisAdminBundle:Admin:Briques/briques_modifier.html.twig', array(
'brique' => $brique,
'form' => $form->createView(),
));
} |
Partager