/**
  * Transforms an object (evenement) to a string (number).
  *
  * @param  Evenement|null $evenement
  * @return string
  */
 public function transform($evenement)
 {
     if (null === $evenement) {
         return '';
     }
     return $evenement->getId();
 }
 /**
  * Displays a form to create a new Evenement entity.
  *
  * @Route("/new", name="evenement_new")
  * @Route("/new/{candidature_id}/{ajax}", name="evenement_new_2", defaults={"candidature_id" = null ,"ajax" = 0})
  * @Method("GET")
  */
 public function newAction($candidature_id = null, $ajax = 0)
 {
     $entity = new Evenement();
     $request = Request::createFromGlobals();
     $options = array();
     if (!is_null($candidature_id)) {
         $em = $this->getDoctrine()->getManager();
         $candidature = $em->getRepository('CandidaturesBundle:Candidature')->find($candidature_id);
         $entity->setCandidature($candidature);
         $options['candidature'] = 'hide';
     }
     $form = $this->createCreateForm($entity, $options);
     if ($ajax || $request->isXmlHttpRequest()) {
         return $this->render('CandidaturesBundle:Evenement:form_new.html.twig', array('form' => $form->createView(), 'ajax' => true));
     }
     return $this->render('CandidaturesBundle:Evenement:new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'ajax' => false));
 }