private function makeMatchForm(MatchForm $matchForm, $action) { $teams = $this->get('logic')->listTeamsByGroup($matchForm->getGroup()->getId()); $teamnames = array(); foreach ($teams as $team) { $teamnames[$team->id] = $team->name; } $show = $action != 'del'; $extshow = $show && !$this->get('match')->isMatchResultValid($matchForm->getId()); $formDef = $this->createFormBuilder($matchForm); $formDef->add('teamA', 'choice', array('label' => 'FORM.MATCH.HOME', 'choices' => $teamnames, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$extshow, 'translation_domain' => 'admin')); $formDef->add('teamB', 'choice', array('label' => 'FORM.MATCH.AWAY', 'choices' => $teamnames, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$extshow, 'translation_domain' => 'admin')); $formDef->add('cancel', 'submit', array('label' => 'FORM.MATCH.CANCEL.' . strtoupper($action), 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times')); $formDef->add('save', 'submit', array('label' => 'FORM.MATCH.SUBMIT.' . strtoupper($action), 'translation_domain' => 'admin', 'icon' => 'fa fa-check')); return $formDef->getForm(); }
private function addMatch(MatchForm $matchForm) { $match = new Match(); $match->setGroup($matchForm->getGroup()); $this->updateMatch($matchForm, $match); $em = $this->getDoctrine()->getManager(); $em->persist($match); $em->flush(); }