Skip to content

Instantly share code, notes, and snippets.

@ornicar
Created September 23, 2011 13:56
Show Gist options
  • Save ornicar/1237393 to your computer and use it in GitHub Desktop.
Save ornicar/1237393 to your computer and use it in GitHub Desktop.
public function editAction($id)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('LapaperieFocusBundle:Focus')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Focus entity.');
}
$editForm = $this->createForm(new FocusType(), $entity);
$deleteForm = $this->createDeleteForm($id);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$editForm->bindRequest($request);
if ($editForm->isValid()) {
//TODO -> vérifier le focntionnemetn d'accès aux variables $_POST
$request_args = $request->request->get('lapaperie_focusbundle_focustype');
isset($request_args['isOnLine'])?$isOnLine = true:$isOnLine = false ;
if($isOnLine)
{
$em1 = $this->getDoctrine()->getEntityManager();
$repository = $em1->getRepository('LapaperieFocusBundle:Focus')->setOthersOffLine($id);
}
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('focus_edit', array('id' => $id)));
}
}
return array(
'entity' => $entity,
'form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment