public function executeListBooking(sfWebRequest $request) { $this->form = new BookingForm(); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $values = $this->form->getValues(); $emails = $values['input']; $tournament = TournamentTable::getInstance()->findOneById($values['tournament']); $num = 0; foreach ($emails as $email => $nick) { $count = PlayerTable::getInstance()->findOneByEmail($email); if ($count) { $num++; $this->getUser()->setFlash('error', $num . " joueurs déja inscrit(s).", false); } else { $player = $this->createBookedPlayer($email, $nick, $tournament); $this->sendConfirmationMail($player); } } $this->getUser()->setFlash('notice', count($emails) - $num . " joueurs inscrits.", false); } else { $this->getUser()->setFlash('error', "Erreurs dans le formulaire.", false); } } }
public function executeStep1(sfWebRequest $request) { $event = EventTable::getInstance()->findUpComingEvent(); $this->forwardClosedIfNoEventUpcoming(); $this->form = new TournamentChooserForm(array(), array('event' => $event)); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $tid = $request->getParameter('tournament'); $tournament = TournamentTable::getInstance()->findOneById($tid); $this->getUser()->setAttribute('tournament', $tournament); $this->redirect("registration/step2"); } else { $this->getUser()->setFlash('error', "Erreurs dans le formulaire.", false); } } }
public function configure() { $table = TournamentTable::getInstance()->findAll(); $tournaments = array(); foreach ($table as $tournament) { $tournaments[$tournament->getId()] = $tournament->getEvent()->getName() . ' » ' . $tournament->getName(); if ($tournament->isFull()) { $tournaments[$tournament->getId()] .= " (complet)"; } } // Tournament chooser field $this->setWidget('tournament', new sfWidgetFormChoice(array('choices' => $tournaments, 'expanded' => false))); $this->setValidator('tournament', new sfValidatorChoice(array('choices' => array_keys($tournaments)))); $this->widgetSchema->setLabel('tournament', 'Choisissez un tournoi :'); // Input chooser field $this->setWidget('input', new sfWidgetFormTextarea()); $this->setValidator('input', new sfValidatorBooking()); $this->widgetSchema->setLabel('input', 'Liste'); $this->widgetSchema->setHelp('input', 'Entrer une liste de joueurs au format suivant :<br/> [pseudo]:[email]'); }