private function makeUpdMatchForm(MatchForm $matchForm, Match $match)
 {
     /* @var $qmh QMatchRelation */
     $qmh = $this->get('match')->getQMatchRelationByMatch($match->getId(), false);
     $teamListA = $this->get('orderTeams')->sortGroup($qmh->getGroup()->getId());
     $teamnamesA = array();
     foreach ($teamListA as $team) {
         $teamnamesA[$team->id] = $team->name;
     }
     $teamA = $teamListA[$qmh->getRank() - 1];
     $matchForm->setTeamA($teamA->id);
     /* @var $qma QMatchRelation */
     $qma = $this->get('match')->getQMatchRelationByMatch($match->getId(), true);
     $teamListB = $this->get('orderTeams')->sortGroup($qma->getGroup()->getId());
     $teamnamesB = array();
     foreach ($teamListB as $team) {
         $teamnamesB[$team->id] = $team->name;
     }
     $teamB = $teamListB[$qma->getRank() - 1];
     $matchForm->setTeamB($teamB->id);
     $show = true;
     $extshow = $show && !$this->get('match')->isMatchResultValid($matchForm->getId());
     $formDef = $this->createFormBuilder($matchForm);
     $formDef->add('teamA', 'choice', array('label' => 'FORM.MATCH.HOME', 'choices' => $teamnamesA, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$extshow, 'translation_domain' => 'admin'));
     $formDef->add('teamB', 'choice', array('label' => 'FORM.MATCH.AWAY', 'choices' => $teamnamesB, 'empty_value' => 'FORM.MATCH.DEFAULT', 'required' => false, 'disabled' => !$extshow, 'translation_domain' => 'admin'));
     $formDef->add('cancel', 'submit', array('label' => 'FORM.MATCH.CANCEL.CHG', 'translation_domain' => 'admin', 'buttontype' => 'btn btn-default', 'icon' => 'fa fa-times'));
     $formDef->add('save', 'submit', array('label' => 'FORM.MATCH.SUBMIT.CHG', 'translation_domain' => 'admin', 'icon' => 'fa fa-check'));
     return $formDef->getForm();
 }
 private function checkForm($form, MatchForm $matchForm)
 {
     if (!$form->isValid()) {
         return false;
     }
     if ($matchForm->getMatchno() == null || trim($matchForm->getMatchno()) == '') {
         $form->addError(new FormError($this->get('translator')->trans('FORM.MATCH.NONO', array(), 'admin')));
     }
     if ($matchForm->getDate() == null || trim($matchForm->getDate()) == '') {
         $form->addError(new FormError($this->get('translator')->trans('FORM.MATCH.NODATE', array(), 'admin')));
     } else {
         $date = date_create_from_format($this->get('translator')->trans('FORMAT.DATE'), $matchForm->getDate());
         if ($date === false) {
             $form->addError(new FormError($this->get('translator')->trans('FORM.MATCH.BADDATE', array(), 'admin')));
         }
     }
     if ($matchForm->getTime() == null || trim($matchForm->getTime()) == '') {
         $form->addError(new FormError($this->get('translator')->trans('FORM.MATCH.NOTIME', array(), 'admin')));
     } else {
         $time = date_create_from_format($this->get('translator')->trans('FORMAT.TIME'), $matchForm->getTime());
         if ($time === false) {
             $form->addError(new FormError($this->get('translator')->trans('FORM.MATCH.BADTIME', array(), 'admin')));
         }
     }
     if ($matchForm->getPlayground() == null) {
         $form->addError(new FormError($this->get('translator')->trans('FORM.MATCH.NOPLAYGROUND', array(), 'admin')));
     }
     return $form->isValid();
 }