コード例 #1
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @Route(path="/addMany",name="bde_wei_bungalow_add_many")
  * @Method({"GET","POST"})
  */
 public function addManyAction(Request $request)
 {
     // Get data from Form
     // The way to use a get from the request is bad but on one side you can't use symfony form on GET request
     // And on the other way you can't put it as url param because it comes from a form and JS is bad !
     $amount = $this->getRequest()->get("nbBung");
     $em = $this->getDoctrine()->getManager();
     $nbBung = $amount;
     if ($amount <= 0) {
         throw new \InvalidArgumentException("Amount of bungalow can not be less than 1");
     }
     for ($i = 0; $i < $nbBung; $i++) {
         $bungalow = new Bungalow();
         $bungalow->setNom("Bung " . $i);
         $bungalow->setNbPlaces(6);
         $em->persist($bungalow);
         $em->flush();
     }
     return $this->redirect($this->generateUrl('cva_gestion_membre_config'));
 }
コード例 #2
0
 protected function configureDatagridFilters(DatagridMapper $filter)
 {
     $filter->add('nom')->add('sexe', 'doctrine_orm_string', array(), 'choice', array('choices' => Bungalow::getSexChoices(), 'multiple' => false, 'required' => false));
 }