Example #1
0
 public function createComponentRaceForm()
 {
     $validator = function ($item) {
         return $this->race->freeRaceid($item->value);
     };
     $form = new Form();
     $i = $form->addText('raceid', 'ID závodu:');
     if ($this->getAction() == 'add') {
         $i->setRequired('ID závodu je povinné')->addRule(Form::LENGTH, 'Délka ID musí být 4 - 8 znaků', array(4, 8))->addRule($validator, 'ID je již použito.');
     } else {
         $i->setDisabled(TRUE);
     }
     $form->addText('name', 'Název:');
     $form->addDateTimePicker('datetime_0', 'Datum a čas:')->setRequired('Datum a čas jsou povinné.');
     $form->addSelect('type', 'Typ závodu', self::$race_type);
     $form->addSelect('opt_preftype', 'Druh závodu', self::$race_kind);
     $form->addSelect('opt_incomplete', 'Při chybějící kontrole', self::$inco_list);
     $form->addCheckbox('opt_autocat', 'Automatická kategorie');
     $form->addCheckbox('opt_namefrsi', 'Doplnit jméno z SI čipu');
     $form->addCheckbox('opt_addnew', 'Hodnotit i nepřihlášené');
     $form->addTextArea('descr', 'Popis:');
     $form->addSubmit('send', 'OK');
     $form->addSubmit('cancel', 'Zpět')->setValidationScope(false)->onClick[] = [$this, 'formCancelled'];
     if ($this->getAction() == 'add') {
         $form->onSuccess[] = [$this, 'addRaceFormSucceeded'];
     } else {
         $form->onSuccess[] = [$this, 'editRaceFormSucceeded'];
     }
     $form->setRenderer(new Bs3FormRenderer());
     return $form;
 }