Exemplo n.º 1
0
 protected function createComponentRegisterForm()
 {
     $form = new Nette\Application\UI\Form();
     $form->addText('nickname', 'Nickname')->setRequired();
     $form->addText('email', 'Email')->setRequired();
     $form->addPassword('password', 'Password')->setRequired();
     $form->addRadioList('tribe', 'Choose tribe', [1 => 'Romans', 2 => 'Teutons', 3 => 'Gauls'])->setRequired();
     $form->addRadioList('position', 'Starting position', [0 => 'Random', 1 => 'North west (+|-)', 2 => 'South west (-|-)', 3 => 'North east (+|+)', 4 => 'South east (+|-)'])->setDefaultValue(0)->setRequired();
     $form->addCheckbox('accept', 'I accept the game rules and general terms and conditions.')->setRequired();
     $form->addSubmit('signup', 'Signup');
     $form->onSuccess[] = [$this, 'processRegistration'];
     return $form;
 }
Exemplo n.º 2
0
  /**
 * Edit hlavne menu form component factory.
 * @return Nette\Application\UI\Form
 */
  public function create($iko, $upload_size)
  {
      $form = new Form();
      $form->addProtection();
      $form->addHidden("id");
      $form->addHidden("id_lang");
      $form->addHidden("spec_nazov");
      $form->addUpload('title_image', 'Titulný obrázok:')->setOption('description', 'Odporúčaný rozmer obrázku je: 90x70px alebo násobky tejto veľkosti. Inak môže dôjsť k deformácii alebo orezaniu obrázku pri ukladaní!')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'Titulný obrázok musí byť JPEG, PNG alebo GIF.')->addRule(Form::MAX_FILE_SIZE, 'Maximálna veľkosť súboru je 64 kB.', 64 * 1024);
      $form->addText('nazov', 'Názov produktu:', 50, 50)->setRequired('Názov musí byť zadaný!');
      $form->addRadioList('tepkat', 'Tepelná kategória:', $iko)->getSeparatorPrototype()->setName(NULL);
      $form->addText('vyska', 'Výška[mm]:', 5, 5)->addRule(Form::RANGE, 'Výška musí byť v rozsahu od %d do %d mm!', array(0, 4000))->setRequired('Výška musí byť zadaná!');
      $form->addText('sirka', 'Šírka[mm]:', 5, 5)->addRule(Form::RANGE, 'Šírka musí byť v rozsahu od %d do %d mm!', array(0, 2000))->setRequired('Šírka musí byť zadaná!');
      $form->addText('hlbka', 'Hĺbka[mm]:', 5, 5)->addRule(Form::RANGE, 'Hĺbka musí byť v rozsahu od %d do %d mm!', array(0, 2000))->setRequired('Hĺbka musí byť zadaná!');
      $form->addText('hmotnost', 'Hmotnosť[kg]:', 5, 5)->addRule(Form::RANGE, 'Hmotnosť musí byť v rozsahu od %d do %d kg!', array(0, 3500))->setRequired('Hmotnosť musí byť zadaná!');
      $form->addText('bottom_plinth_weight', 'Hmotnosť spodného podstavca[kg]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Hmotnosť spodného podstavca musí byť v rozsahu od %d do %d kg!', array(0, 2000));
      $form->addCheckbox('copatible_aurum', ' Kompatibilné s Aurum Pellet Unit');
      $form->addText('termal_energy', 'Tepelná energia[kWh]:', 5, 5)->addRule(Form::RANGE, 'Tepelná energia musí byť v rozsahu od %d do %d kWh!', array(0, 200))->setRequired('Tepelná energia musí byť zadaná!');
      $form->addText('heating_time', 'Čas spaľovania[h:min]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Čas spaľovania musí byť zapísaný v tvare napr.:02:30', '([0-9]\\s*){2}:([0-9]\\s*){2}');
      $form->addText('heating_occasion', 'Max. množstvo dreva[kg]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Max. množstvo dreva musí byť v rozsahu od %d do %d kg!', array(0, 100));
      $form->addText('forewood_lenght', 'Dĺžka dreva do rúry na pečenie[cm]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Dĺžka dreva do rúry na pečenie musí byť v rozsahu od %d do %d cm!', array(0, 100));
      $form->addText('firewood_lenght', 'Dĺžka dreva[cm]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Dĺžka dreva musí byť v rozsahu od %d do %d cm!', array(0, 100));
      $form->addText('nominal_heat_output', 'Nominálny tepelný výkon[kW]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Nominálny tepelný výkon musí byť v rozsahu od %d do %d kW!', array(0, 15));
      $form->addText('nominal_heat_time', 'Nominálny čas[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Nominálny čas musí byť v rozsahu od %d do %d h!', array(0, 50));
      $form->addText('heat_release_time100', 'Tepelná akumulačná kapacita, 100 percent maximálneho výkonu[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Tepelná akumulačná kapacita musí byť v rozsahu od %d do %d h!', array(0, 50));
      $form->addText('heat_release_time50', 'Tepelná akumulačná kapacita, 50 percent maximálneho výkonu[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Tepelná akumulačná kapacita musí byť v rozsahu od %d do %d h!', array(0, 100));
      $form->addText('heat_release_time25', 'Tepelná akumulačná kapacita, 25 percent maximálneho výkonu[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Tepelná akumulačná kapacita musí byť v rozsahu od %d do %d h!', array(0, 100));
      $form->addText('efficiency', 'Účinnosť[%]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Účinnosť musí byť v rozsahu od %d do %d %!', array(0, 100));
      $form->addUpload('pec_pdf', 'Katalógový list vo formáte pdf:')->setOption('description', sprintf('Max veľkosť prílohy v bytoch %s kB', $upload_size / 1024))->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Katalógový list musí byť vo formáte pdf!', 'application/pdf')->addRule(Form::MAX_FILE_SIZE, 'Max veľkosť prílohy može byť v bytoch %d B', $upload_size);
      $form->addSubmit('uloz', 'Ulož produkt');
Exemplo n.º 3
0
 protected function createComponentLayoutForm()
 {
     $layoutPairs = $this->layouts->findAll()->fetchPairs('id', 'slug');
     $form = new Form();
     $form->addRadioList('layouts_id', 'Layout:', $layoutPairs)->setDefaultValue($this->settings->active()->layouts_id);
     $form->addSubmit('set', 'Aktivovat');
     $form->onSuccess[] = array($this, 'registrationFormSucceeded');
     return $form;
 }
Exemplo n.º 4
0
 public function createComponentSurveyForm()
 {
     $form = new Nette\Application\UI\Form();
     $form->addRadioList('mark', 'Aplikaci', [1 => 'navštěvuji denně', 2 => 'používám každý týden', 3 => 'jen když jsem někde byl', 4 => 'vidím poprvé a znova ji nepoužiji'])->setAttribute('class', 'zelená');
     $form->addCheckboxList('mostly', 'Nejčastěji', [1 => 'chodím na tůry do lesa', 2 => 'trávím čas u vody', 3 => 'cestuji do zahraničí', 4 => 'sedím doma'])->setAttribute('class', 'zelená');
     $form->addCheckboxList('future', 'Chci', [1 => 'sdílení výletů', 2 => 'filtrovat výlety v mapě', 3 => 'modul na geoCaching'])->setAttribute('class', 'zelená');
     $form->addSubmit('send', 'Odeslat');
     Helpers::bootstrapForm($form);
     return $form;
 }
Exemplo n.º 5
0
 /**
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentSettingsBackup()
 {
     $form = new Form();
     $form->addGroup('zálohy');
     $form->addText('number', "Max. počet uložených záloh:")->setAttribute('type', 'number')->addRule(Form::INTEGER, "Hodnota musí být číslo.");
     $form->addRadioList('foreign', "Povolit nahrávat vlastních záloh:", array('1' => 'TRUE', '2' => 'FALSE'));
     $form->addSubmit('send', 'Uložit');
     $form->onSuccess[] = $this->settingsBackupSubmitted;
     return $form;
 }
Exemplo n.º 6
0
  private $hlavne_menu;
  /** @var DbTable\User_profiles */
  private $user_profiles;
  /**
 * @param DbTable\Hlavne_menu $hlavne_menu
 * @param DbTable\User_profiles $user_profiles */
  public function __construct(DbTable\Hlavne_menu $hlavne_menu, DbTable\User_profiles $user_profiles)
  {
      $this->hlavne_menu = $hlavne_menu;
      $this->user_profiles = $user_profiles;
  }
Exemplo n.º 7
0
 protected function createComponentThemeForm()
 {
     $themePairs = $this->themes->findAll()->fetchPairs('id', 'slug');
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->addRadioList('theme_id', 'Theme', $themePairs)->setDefaultValue($this->settings->active()->themes_id);
     $form->addSubmit('activate', 'Activate');
     $form->onSuccess[] = array($this, 'registrationFormSucceeded');
     return $form;
 }
  private $hlavne_menu;
  /** @var \Nette\Database\Table\Selection */
  private $registracia;
  /**
 * @param DbTable\Hlavne_menu $hlavne_menu
 * @param DbTable\Registracia $registracia */
  public function __construct(DbTable\Hlavne_menu $hlavne_menu, DbTable\Registracia $registracia, User $user)
  {
      $this->hlavne_menu = $hlavne_menu;
      $this->registracia = $registracia->urovneReg($user->getIdentity()->id_registracia);
  }
 /**
  * @param Category[] $categories
  * @param string|null $code
  * @return Form
  */
 public function create($categories, $code = null)
 {
     $validaton_message = "Vyplňte prosím %s. Pomůže mi to lépe zpracovat výsledky průzkumu. Díky ;)";
     $form = new Form($this->parent, $this->name);
     $form->addGroup("Obecné");
     $sex = array(Respondent::GENDER_MALE => 'muž', Respondent::GENDER_FEMALE => 'žena');
     $form->addRadioList('gender', 'Pohlaví:', $sex)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "svoje pohlaví");
     $age = array(Respondent::AGE_15 => 'méne něž 15', Respondent::AGE_15_20 => '15-20', Respondent::AGE_21_30 => '21-30', Respondent::AGE_31_45 => '31-45', Respondent::AGE_46_60 => '46-60', Respondent::AGE_60 => 'více než 60');
     $form->addRadioList('age', 'Věk', $age)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "svůk věk");
     $truefalseoptions = array(1 => "Ano", 0 => "Ne");
     $form->addRadioList("english", "Navštěvuji anglické webové stránky", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda navštěvujete i anglické webové stránky");
     $form->addRadioList("it", "Pracuji v oboru IT nebo tento obor studuji", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda pracujete v oboru IT nebo ho studujete");
     if ($code !== null) {
         $form->addHidden("code", $code);
     }
     $form->addTextArea("sites", "Jaké stránky často navštěvuji");
     $devices = array(Respondent::DEVICE_COMPUTER => "Počítač nebo notebook", Respondent::DEVICE_PHONE => "Smartphone", Respondent::DEVICE_TABLET => "Tablet");
     $form->addCheckboxList('device', 'K přístupu na internet používám:', $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení používáte pro přístup k internetu");
     $form->addRadioList("device_most", "A z toho nejčastěji", $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení nejčastěji používáte pro přístup k internetu");
     $period = array(EntityCategory::PERIOD_NEVER => "vůbec", EntityCategory::PERIOD_DAILY => "denně", EntityCategory::PERIOD_FEW_TIMES_A_WEEK => "několikrát týdně", EntityCategory::PERIOD_FEW_TIMES_A_MONTH => "několikrát měsíčně", EntityCategory::PERIOD_FEW_TIMES_A_YEAR => "několikrát ročně");
     $categories_container = $form->addContainer("category");
     foreach ($categories as $holder_category) {
         $category_container = $categories_container->addContainer($holder_category->getCategory()->id_category);
         $category_container->setCurrentGroup($categories_container->getForm()->addGroup($holder_category->getCategory()->label));
         $category_container->addRadioList("period", "Jak často?", $period)->setAttribute("class", "buttons-group");
         if ($holder_category->getChildren()) {
             $items = array();
             foreach ($holder_category->getChildren() as $child) {
                 $items[$child->id_category] = $child->label;
             }
             $category_container->addCheckboxList("items", $holder_category->getCategory()->child_label, $items)->setAttribute("class", "buttons-group");
         }
     }
     $form->setCurrentGroup(NULL);
     $form->addGroup("Zajímá mě to");
     $form->addText("nickname", "Nick (chci být v highscore)");
     $form->addText("email", "E-mail")->setType("email");
     $form->addTextArea("message", "Vzkaz");
     $form->addSubmit("validate", "Pokračovat")->setAttribute("class", "btn btn-primary");
     $form->addSubmit("nonvalidate", "Přejít rovnou k otázkám")->setValidationScope(FALSE)->setAttribute("class", "btn btn-default");
     return $form;
 }
 public function createComponentOrderForm()
 {
     $form = new Form();
     $radioList = [];
     foreach ($this->genresManager->getAllNonEmptyGenres() as $genre) {
         $radioList[$genre->getId()] = $genre->getName();
     }
     $form->addRadioList('genre', '', $radioList);
     $form->addSubmit('order', 'Objednat');
     $form->onSuccess[] = $this->orderGenre;
     return $form;
 }
Exemplo n.º 11
0
 /**
  * @return Form
  */
 public function createComponentForm()
 {
     $form = new Form();
     $form->addText('name', 'Name:', null, 45)->setRequired('Please fill your name or nick name.')->setValue('Anonymous');
     $form->addTextArea('pros', 'Pros:', null, 5);
     $form->addTextArea('cons', 'Cons:', null, 5);
     $form['pros']->addConditionOn($form['cons'], Form::BLANK, TRUE)->setRequired('Please fill at least Pros or Cons.');
     $form['cons']->addConditionOn($form['pros'], Form::BLANK, TRUE)->setRequired('Please fill at least Pros or Cons.');
     $form->addRadioList('rating', 'Rating:', [1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5])->setRequired('Please select your rating');
     $form->addSubmit('send', 'Save Rating');
     $form->onSuccess[] = array($this, 'formSucceeded');
     return $form;
 }
Exemplo n.º 12
0
 public function createComponentPollieForm()
 {
     $form = new Form();
     $form->addProtection('Control key is not correct. Do another vote.');
     $answers = array();
     foreach ($this->getAnswers() as $answer) {
         $answers[$answer->id] = $answer->getText();
     }
     $form->addRadioList('pollVoteRadiolist', '', $answers)->addRule(Form::FILLED, 'Select an answer.');
     $form->addSubmit('pollVoteSubmit', 'Vote');
     $form->onSuccess[] = array($this, 'onSuccessVote');
     return $form;
 }
Exemplo n.º 13
0
 protected function createComponentRegisterTalkForm()
 {
     $form = new Form();
     $form->addText('name', 'Název')->setRequired();
     $form->addText('subject', 'Obor')->setRequired();
     $form->addTextArea('decription', 'Popis')->setRequired()->addRule(Form::MAX_LENGTH, 'Poznámka je příliš dlouhá', 1000);
     //TODO replace for any lenght
     $form->addRadioList('lenght', 'Délka', array(10 => '15 minut', 25 => '25 minut'))->setRequired();
     $form->addText('email', 'Email')->setRequired()->addRule($form::EMAIL);
     $form->addSubmit('send', 'Registrovat přednášku');
     $form->onSuccess[] = array($this, 'registerTalkFormSucceeded');
     Helpers::bootstrapForm($form);
     return $form;
 }
Exemplo n.º 14
0
 protected function createComponentSearchForm()
 {
     // generate options
     $generalOptions = array('1' => 'Repository', '2' => 'Repository and branches', '3' => 'Repository, branches and tags', '4' => 'Repository, branches, tags and commits');
     $form = new UI\Form();
     // add textinput with validation
     $form->addText('search', 'Search term')->setRequired("Enter text for searching!")->addRule($form::MAX_LENGTH, 'The search text can be a maximum of %d characters', 40);
     // add radiolist with validation
     $form->addRadioList('generalOptions', 'General options:', $generalOptions)->setDefaultValue(true)->setRequired('Enter selections for options!');
     // treatment component and push data to function searchFormSucceeded
     $form->addSubmit('send');
     $form->onSuccess[] = $this->searchFormSucceeded;
     return $form;
 }
Exemplo n.º 15
0
 public function createComponentRandom()
 {
     $session = $this->getSession('random');
     // returns the whole Session
     //dump($session->year);
     if (!isset($session->random)) {
         $session->random = null;
     }
     $form = new UI\Form();
     $form->addRadioList('genres', 'Genres:', array('35' => 'Comedy', '18' => 'Drama', '10749' => 'Romance', '28' => 'Action', '10751' => 'Family', '10402' => 'Music', '99' => 'Documentary', '80' => 'Crime', '53' => 'Thriller', '10752' => 'War', '27' => 'Horror', '37' => 'Western', '12' => 'Adventure', '14' => 'Fantasy', '878' => 'Sci-Fi'))->setDefaultValue($this->getSession('random')->random);
     $form->addSubmit('submit', 'Random');
     $form->onSuccess[] = array($this, 'randomFormSucceeded');
     return $form;
 }
Exemplo n.º 16
0
 protected function createComponentPolozkaForm($name)
 {
     $identifikatory = array('1' => 'prijem', '-1' => 'vydaj');
     $typTransakcie = $this->ciselniktyptransakcie->findAll()->fetchPairs('id', 'nazov');
     $form = new Form();
     $form->addRadioList('identifikator', 'transakcia', $identifikatory)->setRequired();
     $form->addText('popis', 'Popis')->setRequired();
     $form->addDatePicker('datum', 'Datum:', 10, 10)->setRequired();
     $form->addText('suma', 'Suma')->addRule(\Nette\Application\UI\Form::FLOAT, 'Prosim vlozte cislo')->setRequired();
     $form->addSelect('idCiselnikTypTransakcie', 'Typ transakcie', $typTransakcie)->setPrompt('- Zvoľte typ transakcie -')->setRequired();
     $form->addSubmit('save', 'Save')->setAttribute('class', 'default')->onClick[] = $this->vlozitTransakciuFormSucceeded;
     $form->addSubmit('cancel', 'Cancel')->setValidationScope(array())->onClick[] = $this->formCancelled;
     return $form;
 }
Exemplo n.º 17
0
 /**
  * Vytvori formular pro zadani parametru pro vypocet.
  * @return object $form Formular.
  */
 protected function createComponentCalculatorForm()
 {
     $form = new UI\Form();
     $year = $this->database->query('SELECT DISTINCT year FROM sm_bt ORDER BY year DESC')->fetchPairs();
     $sex = ['M' => "Muž", 'F' => "Žena"];
     $course = ['SCM' => "25m", 'LCM' => "50m"];
     $stroke = ["50VZ", "100VZ", "200VZ", "400VZ", "800VZ", "1500VZ", "50Z", "100Z", "200Z", "50P", "100P", "200P", "50M", "100M", "200M", "100PZ", "200PZ", "400PZ", "4x50VZ", '4x100VZ', "4x200VZ", "4x50PZ", "4x100PZ"];
     $mode = array('time' => 'Čas', 'points' => 'Body');
     $form->addSelect('year', 'Rok FINA bodů')->setItems($year, FALSE)->setRequired('Prosím zvolte rok FINA bodů.')->setValue($this->database->query('SELECT DISTINCT MAX(year) FROM sm_bt')->fetchField());
     $form->addRadioList('sex', 'Pohlaví:', $sex);
     $form->addRadioList('course', 'Bazén:', $course);
     $form->addSelect('stroke', 'Styl')->setPrompt('- Styl -')->setRequired('Prosím zvolte plavecký styl.')->setItems($stroke, FALSE);
     $form->addCheckbox('time');
     $form->addRadioList('mode', 'Zadej:', $mode);
     $form->addText('time_min')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'Položka minuty musí být číselná hodnota.')->addRule(Form::RANGE, 'Položka minuty musí být v rozmezí 0 až 59.', array(0, 59));
     $form->addText('time_sec')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'Položka sekundy musí být číselná hodnota.')->addRule(Form::RANGE, 'Položka sekundy musí být v rozmezí 0 až 59.', array(0, 59));
     $form->addText('time_dec')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'Položka setiny musí být číselná hodnota.')->addRule(Form::RANGE, 'Položka setiny musí být v rozmezí 0 až 99.', array(0, 99));
     $form->addCheckbox('points');
     $form->addText('points_box')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'Položka body musí být číselná hodnota.')->addRule(Form::RANGE, 'Položka body musí být v rozmezí 1 až 2000.', array(1, 2000));
     $form->addSubmit('calculate');
     $form->onSuccess[] = array($this, 'calculatorFormSucceeded');
     return $form;
 }
Exemplo n.º 18
0
             $this->setView("default");
         } else {
             //Ak je vsetko OK priprav premenne
             $this->flashRedirect('Pokladnicka:', 'Došlo k chybe. K id neexzistuje položka.', 'danger');
         }
     } else {
         $this->flashRedirect('Pokladnicka:', 'Došlo k chybe. Neviem id položky.', 'danger');
     }
 }
 public function renderDefault()
 {
     $this->template->pokladnicka = $this->pokladnicka->pokladnicka();
     $this->template->h2 = 'Pokladnička:';
     $this->template->h4 = $this->h4;
 }
Exemplo n.º 19
0
 public function createComponentEntryCopyForm()
 {
     $form = new Form();
     $raceentry = $form->addMultiSelect('raceentry', 'Přihlášky závodu:', $this->entry->listNames())->addRule(Form::FILLED, "Nic není označeno.");
     $raceentry->getControlPrototype()->size(25);
     $globalentry = $form->addMultiSelect('globalentry', 'DB závodníků :', $this->entry->listNames(Entry::GLOBTB))->addRule(Form::FILLED, "Nic není označeno.");
     $globalentry->getControlPrototype()->size(25);
     $form->addRadioList('si_collision', 'Stejné SI:', self::$collision_options)->setValue(Entry::COLL_ADD);
     $form->addSubmit('torace', '<span class="glyphicon glyphicon-arrow-left"></span>')->setValidationScope([$globalentry])->getControlPrototype()->addClass('btn-default');
     $form->addSubmit('toglobal', '<span class="glyphicon glyphicon-arrow-right"></span>')->setValidationScope([$raceentry])->getControlPrototype()->addClass('btn-default');
     $form->onSuccess[] = [$this, 'entryCopyFormSucceeded'];
     $form->setRenderer(new Bs3FormRenderer());
     return $form;
 }
Exemplo n.º 20
0
 /**
  * @return Form
  */
 public function create($to)
 {
     $form = new Form();
     $form->addText('fullname', 'Celé jméno:')->setRequired('Prosím vyplňte Vaše jméno.');
     $form->addText('email', 'E-mail:')->addRule(Form::FILLED, 'Vyplňte Váš email.')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Neplatná emailová adresa.');
     $form->addPassword('password', 'Heslo:')->setRequired('Prosím vyplňte Vaše heslo')->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaků.', 6);
     $form->addPassword('password2', 'Heslo znovu: ')->addConditionOn($form['password'], Form::VALID)->addRule(Form::FILLED, 'Napište Vaše heslo znovu.')->addRule(Form::EQUAL, 'Hesla se neshodují.', $form['password']);
     $role = array('student' => 'Student', 'teacher' => 'Učitel');
     $role = $form->addRadioList('role', 'Kdo jsi?', $role)->setDefaultValue('student');
     // $cookie = $httpRequest->getCookie('to');
     if ($to == 'new') {
         $role->setDefaultValue('teacher');
     }
     $form->addSubmit('send', 'Zaregistrovat se');
     $form->onSuccess[] = array($this, 'formSucceeded');
     return $form;
 }
Exemplo n.º 21
0
 public function create()
 {
     $form = new Form();
     $form->addText("title")->addRule(Form::MAX_LENGTH, "Maximální délka nadpisu může být %d znaků.", Article::MAX_TITLE_LENGTH)->setRequired("Zadej prosím nadpis článku.");
     $form->addTextArea("content")->setAttribute("rows", 15)->setAttribute("cols", 7)->setRequired("Zadej prosím text článku.");
     $form->addCheckboxList("categories", null, $this->categories)->setRequired("Vyber prosím alespoň jednu kategorii.");
     $form->addText("tags")->setAttribute("size", 30);
     $form->addButton("addTag");
     $form->addRadioList("publishedAt", null, array("now" => "Publikovat ihned", "noChange" => "Ponechat stávající", "later" => "Naplánovat na"))->setRequired("Zadej prosím datum vydání.");
     $form->addText("day")->setAttribute("size", 2)->setRequired("Zadej prosím den vydání.")->addRule(Form::RANGE, "Den musí být číselná hodnota v intervalu %d až %d.", array(1, 31))->setDefaultValue(date("j"));
     $form->addSelect("month")->setItems(DateTimeUtils::getMonths(), true)->setDefaultValue(date("n"));
     $form->addSelect("year")->setItems(DateTimeUtils::getYears(), false)->setDefaultValue(date("Y"));
     $form->addText("hour")->setAttribute("size", 2)->setRequired("Zadej prosím hodinu vydání.")->addRule(Form::RANGE, "Hodina musí být číselná hodnota v intervalu %d až %d.", array(0, 23))->setDefaultValue(date("H"));
     $form->addText("minute")->setAttribute("size", 2)->setRequired("Zadej prosím minutu vydání.")->addRule(Form::RANGE, "Minuta musí být číselná hodnota v intervalu %d až %d.", array(0, 59))->setDefaultValue(date("i"));
     $form->addSubmit("submit");
     $form->onValidate[] = array($this, "validateAddArticleForm");
     $form->onSuccess[] = array($this, "addArticleFormSucceeded");
     return $form;
 }
Exemplo n.º 22
0
class EditPokladnickaFormFactory
{
    /** @var DbTable\Pokladnicka */
    private $pokladnicka;
    /**
   * @param DbTable\Pokladnicka $pokladnicka
   * @param DbTable\User_profiles $user_profiles */
    public function __construct(DbTable\Pokladnicka $pokladnicka)
    {
        $this->pokladnicka = $pokladnicka;
    }
    /**
   * Formular pre pridanie a aditaciu poloziek pokladnicky.
   * @param int $id Id polozky
   * @return Nette\Application\UI\Form */
    public function create($id = 0)
    {
        $form = new Form();
        $form->addProtection();
        $form->addHidden("id");
Exemplo n.º 23
0
 public function createComponentContactForm()
 {
     $form = new Form();
     $form->addText('name', 'Your name:')->setRequired();
     $form->addText('email', 'Your e-mail:')->setType('email')->addRule(Form::EMAIL, 'That doesn\'t look like a proper e-mail address. Please check your e-mail address for typos and send the form again.');
     $form->addText('phone', 'Your phone number:')->setType('tel')->addRule(Form::PATTERN, 'Please specify your phone number in the international format', '(00|\\+)[\\d\\s]+');
     $form->addRadioList('preferred', 'Preferred contact:', ['phone' => 'Phone', 'email' => 'E-mail'])->setRequired();
     $subjects = ['general' => 'General Questions', 'complaint' => 'Quality of Service Complaints', 'idea' => 'Ideas for Improvement'];
     $form->addSelect('topic', 'Message topic:', $subjects)->setRequired();
     $form->addTextArea('content', 'Your message:', 40, 4)->setRequired();
     $form->addUpload('attachments', 'Attachments (only JPEG images allowed):', true)->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Only JPEG images are allowed', 'image/jpeg');
     $newsletters = ['weekly' => 'Weekly reports', 'promo' => 'Promotional bulletins', 'ads' => 'Interesting offers'];
     $form->addCheckboxList('subscribe', 'Subscribe to:', $newsletters);
     $form->addCheckbox('terms', 'I agree to the terms and conditions')->setOmitted()->setRequired();
     $form->addSubmit('send', 'Send message')->onClick[] = [$this, 'informMessageSent'];
     $form->addSubmit('save', 'Save message')->onClick[] = [$this, 'informMessageSaved'];
     $form->onSuccess[] = [$this, 'doSendMessage'];
     return $form;
 }
Exemplo n.º 24
0
 public function createComponentDemoForm()
 {
     $form = new Form();
     if (class_exists('Instante\\Bootstrap3Renderer\\BootstrapRenderer')) {
         $form->setRenderer(new BootstrapRenderer());
     }
     $form->addGroup('Text fields');
     $form->addText('email', 'Email')->setType('email')->setOption('placeholder', 'Email');
     $form->addTextArea('textarea', 'Textarea');
     $form->addPassword('password', 'Heslo')->setOption('placeholder', 'Heslo');
     $form->addGroup('Other fields');
     $form->addSelect('select', 'Select', ['foo' => 'Foo', 'bar' => 'Bar'])->setPrompt('-choose-')->addError('This field is in an error state');
     $form->addCheckboxList('checkboxlist', 'Checkbox List', ['foo' => 'Foo', 'bar' => 'Bar']);
     $form->addRadioList('rlist', 'Radio List', ['foo' => 'Foo', 'bar' => 'Bar']);
     $form->addCheckbox('remember', 'Neodhlašovat');
     $form->addSubmit('send', 'Přihlásit')->setOption('btn-class', 'btn-primary');
     $form->addSubmit('s2', 'Submit 2');
     $form->addError('This is global form error');
     return $form;
 }
Exemplo n.º 25
0
 /**
  * @return Form
  */
 public function create($id = null)
 {
     $this->id = $id;
     $form = new Form();
     $form->getElementPrototype()->class('ajax form');
     if ($this->id == null) {
         $form->addText('nick', 'Nick')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole Nick.');
         $form->addPassword('password', 'Heslo', 20)->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole Heslo.')->addRule(Form::MIN_LENGTH, 'Zadejte prosím heslo obsahující alespoň %d znaků.', 6);
         $form->addPassword('password2', 'Heslo znovu', 20)->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole Heslo znovu.')->addConditionOn($form['password'], Form::VALID)->addRule(Form::EQUAL, 'Hesla se neshodují. Zadejte a ověřte heslo znovu.', $form['password']);
     }
     $form->addText('name', 'Celé jméno')->setAttribute('class', 'form-control form-control-active')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole Celé jméno.');
     $sex = array('1' => 'muž', '2' => 'žena');
     $form->addRadioList('id_gender', 'Pohlaví', $sex)->getSeparatorPrototype()->setName(NULL)->setAttribute('class', 'radio')->setRequired('Vyberte prosím pohlaví.');
     $form->addText('address', 'Adresa')->setAttribute('class', 'form-control form-control-active')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole Adresa.');
     $form->addText('email', 'E-mail', 35)->setType('email')->setAttribute('class', 'form-control form-control-active')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole E-mail.')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Vložte prosím platnou emailovou adresu.');
     $form->addText('phone', 'Telefon')->setAttribute('class', 'form-control form-control-active')->setAttribute('placeholder', 'Nevyplněno')->setRequired('Vyplňte prosím pole Telefon.');
     $form->addSubmit('send', 'Registrovat')->setAttribute('class', 'btn btn-primary');
     $form->onSuccess[] = array($this, 'formSucceeded');
     $form->onError[] = array($this, 'formNotSucceeded');
     return $form;
 }
Exemplo n.º 26
0
 public function createComponentExampleOneForm()
 {
     $form = new Form();
     $form->addText('name', "Name:");
     $form->addPassword('password', "Password:"******"Textarea");
     $form->addSelect('select', "Select", ['Option 1', 'Option 2']);
     $form->addUpload('upload', 'Upload');
     $form->addCheckbox('checkbox', 'Checkbox');
     $form->addRadioList('radioList', 'Radio list', ['Item A', 'Item B']);
     $form->addCheckboxList('checkboxList', 'Checkbox list,', ['Item A', 'Item B']);
     $form->addText('date', 'Date:')->getControlPrototype()->class('b-date-input');
     $form->addText('datetime', 'Date time:')->getControlPrototype()->class('b-date-input b-date-input--datetime');
     $now = new DateTime();
     $now->modify('+1 day');
     $now->modify('+3 hour');
     $form->setDefaults(['date' => $now, 'datetime' => $now]);
     $form->addSubmit('actionSend', 'Save');
     $form->onSuccess[] = array($this, 'exampleOneFormSubmitted');
     return $form;
 }
Exemplo n.º 27
0
 protected function createComponentSendUnitsForm()
 {
     $form = new Nette\Application\UI\Form();
     $form->addText('1', '1');
     $form->addText('2', '2');
     $form->addText('3', '3');
     $form->addText('4', '4');
     $form->addText('5', '5');
     $form->addText('6', '6');
     $form->addText('7', '7');
     $form->addText('8', '8');
     $form->addText('9', '9');
     $form->addText('10', '10');
     $form->addText('11', '11');
     $sendTypes = [1 => 'Reinforcement', 2 => 'Normal attack', 3 => 'Raid'];
     $form->addRadioList('type', '', $sendTypes)->setDefaultValue(1);
     $form->addText('village', 'Village');
     $form->addText('x', 'X')->setDefaultValue($this->wdata->x);
     $form->addText('y', 'Y')->setDefaultValue($this->wdata->y);
     $form->addSubmit('ok', 'OK');
     $form->onSuccess[] = [$this, 'renderReview'];
     return $form;
 }
Exemplo n.º 28
0
 /**
  * Components for all the forms, to keep the API same
  */
 protected function appendControls(\Nette\Application\UI\Form $form)
 {
     // General form errors
     $form->addError('This is a generic form error.');
     // Showcase
     $form->addText('simple', 'Simple input');
     $form->addText('placeholder', 'Input with placeholder')->setOption('placeholder', 'This is a placeholder value');
     $form->addText('help', 'Simple input with help')->setOption('help', 'This is some help text');
     $form->addText('help_block', 'Help with block style')->setOption('help', 'This is some help text')->setOption('help-style', 'block');
     $form->addText('status_warning', 'Simple input with warning')->setOption('status', 'warning');
     $form->addText('status_error', 'Simple input with error')->setOption('status', 'error');
     $form->addText('status_success', 'Simple input with success')->setOption('status', 'success');
     $form->addText('prepend_append', 'Prepend and append')->setOption('prepend', '$')->setOption('append', '.00');
     $form->addTextArea('textarea', 'Some textarea');
     // Prepend & append with buttons
     $form->addText('prepend_append_buttons', 'Prepend and append BUTTONS')->setOption('prepend', 'butt prepend')->setOption('append', 'butt append')->setOption('prepend-button', 'html-id-prepend')->setOption('append-button', 'html-id-append')->setOption('prepend-button-class', 'btn-primary')->setOption('append-button-class', 'btn-success');
     // Checkboxes - standard
     $form->addCheckbox('chks1', 'Standard checkbox 1');
     $form->addCheckbox('chks2', 'Standard checkbox 2');
     // Checkboxes - inline
     $form->addCheckbox('chki1', 'first')->setOption('inline', true)->setOption('label', 'Inline checkboxes');
     $form->addCheckbox('chki2', 'second')->setOption('inline', true);
     $form->addCheckbox('chki3', 'third')->setOption('inline', true);
     // Radio buttons
     $form->addRadioList('radiolist', 'Radio lists', array('first' => 'This is first radio option', 'second' => 'This is second radio option'));
     // Selects
     $form->addSelect('select', 'Simple select', array('one' => 'First option', 'two' => 'Second option', 'three' => 'Third option', 'four' => 'Fourth option'), 1);
     $form->addSelect('multiselect', 'Multiselect', array('one' => 'First option', 'two' => 'Second option', 'three' => 'Third option', 'four' => 'Fourth option', 'fifth' => 'Fifth option'), 2)->setOption('help', 'Sorry about the fact that Bootstrap does not have size element available; you need to style this one yourself...')->setOption('help-style', 'block');
     // Styles on individual controls
     $form->addText('input_with_class', 'Input with class')->getControlPrototype()->readonly = 'readonly';
     // Disabled input
     $form->addText('disabled', 'Disabled input')->setDisabled(true);
     // Required input
     $form->addText('required', 'Required input')->setRequired('This input is required');
     // Input with error on it via Nette
     $form->addText('error', 'Nette error showcase')->addError('Field cannot be empty');
 }
Exemplo n.º 29
0
 public function createComponentPaymentAndShippingForm()
 {
     //$countries = $this->context->createReference()->getReference('country')->where('hidden', 0)->order('id')->fetchPairs('id', 'name_full');
     $totalPrice = $this->cart->getTotalPrice(\CartItem::ITEM_NORMAL);
     if ($totalPrice >= $this->noShippingLimit) {
         $paymentType = $this->context->createReference()->getReference('payment')->where('name_nm', array('BANK'))->order('name_full')->fetchPairs('name_nm', 'name_full');
         $shippingTypeBank = $this->context->createReference()->getReference('shipping')->where('name_nm', array('PERSON', 'SAVE', 'DPD'))->order('name_full')->fetchPairs('name_nm', 'name_full');
         $shippingTypeCash = $this->context->createReference()->getReference('shipping')->where('name_nm', array())->fetchPairs('name_nm', 'name_full');
         $shippingTypeCod = $this->context->createReference()->getReference('shipping')->where('name_nm', array())->fetchPairs('name_nm', 'name_full');
     } else {
         $paymentType = $this->context->createReference()->getReference('payment')->where('name_nm', array('CASH', 'BANK', 'COD'))->order('name_full')->fetchPairs('name_nm', 'name_full');
         $shippingTypeCash = $this->context->createReference()->getReference('shipping')->where('name_nm', array('PERSON', 'SAVE'))->fetchPairs('name_nm', 'name_full');
         $shippingTypeBank = $this->context->createReference()->getReference('shipping')->where('name_nm', array('PERSON', 'SAVE', 'DPD'))->order('name_full')->fetchPairs('name_nm', 'name_full');
         $shippingTypeCod = $this->context->createReference()->getReference('shipping')->where('name_nm', array('DPD'))->fetchPairs('name_nm', 'name_full');
     }
     $saveList = $this->context->createReference()->getReference('save')->where('active', 1)->fetchPairs('id', 'name_full');
     $form = new Form();
     $form->addGroup('Způsob platby');
     $form->addRadioList('payment', 'Způsob platby', $paymentType)->addCondition(Form::EQUAL, 'CASH')->toggle('CASH')->addCondition(Form::EQUAL, 'BANK')->toggle('BANK')->addCondition(Form::EQUAL, 'COD')->toggle('COD');
     $form->addGroup('Doprava')->setOption('container', Html::el('fieldset')->id("CASH")->style("display:none"));
     $form->addRadioList('shippingCash', 'Způsob dopravy', $shippingTypeCash);
     $form->addSelect('saveListCash', 'Pobočka uloženky', $saveList)->setPrompt('- Vyberte pobočku -');
     $form->addGroup('Doprava')->setOption('container', Html::el('fieldset')->id("BANK")->style("display:none"));
     $form->addRadioList('shippingBank', 'Způsob dopravy', $shippingTypeBank);
     $form->addSelect('saveListBank', 'Pobočka uloženky', $saveList)->setPrompt('- Vyberte pobočku -');
     $form->addGroup('Doprava')->setOption('container', Html::el('fieldset')->id("COD")->style("display:none"));
     $form->addRadioList('shippingCod', 'Způsob dopravy', $shippingTypeCod);
     $form->addGroup('Doručovací údaje');
     $form->addText('name', 'Jméno:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat jméno.')->setAttribute('class', 'text');
     $form->addText('surname', 'Příjmení:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat příjmení.')->setAttribute('class', 'text');
     $form->addText('phone', 'Telefonní číslo:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat telefon.')->setAttribute('class', 'text')->addRule(Form::INTEGER, 'Telefon musí být složen jen z čísel.');
     $form->addText('email', 'E-mail:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat e-mail.')->setAttribute('class', 'text')->addRule(Form::EMAIL, 'Pole email musí obsahovat platnou emailovou adresu.');
     $form->addText('street', 'Ulice:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat ulici.')->setAttribute('class', 'text');
     $form->addText('city', 'Město:*', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat město.')->setAttribute('class', 'text');
     $form->addText('zipcode', 'PSČ*:', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat PSČ.')->setAttribute('class', 'text');
     $form->addGroup('Poznámka');
     $form->addTextArea('note', 'Poznámka k objednávce', 100, 7);
     if ($this->getUser()->isLoggedIn()) {
         $form->setDefaults(array('payment' => 'CASH', 'shippingCash' => 'PERSON', 'shippingBank' => 'DPD', 'shippingCod' => 'SAVE', 'name' => $this->customerInformation['name'], 'surname' => $this->customerInformation['surname'], 'phone' => $this->customerInformation['phone'], 'email' => $this->customerInformation['email'], 'street' => $this->customerAddress['street'], 'city' => $this->customerAddress['city'], 'zipcode' => $this->customerAddress['zipcode'], 'country_id' => 1));
     } else {
         $form->setDefaults(array('payment' => 'CASH', 'shippingCash' => 'PERSON', 'shippingBank' => 'DPD', 'shippingCod' => 'SAVE'));
     }
     if ($totalPrice >= $this->noShippingLimit) {
         $form->setDefaults(array('payment' => 'BANK', 'shippingBank' => 'PERSON'));
     }
     $form->setCurrentGroup(null);
     $form->addSubmit('submit', 'Potvrdit')->setAttribute('class', 'button floatLeft')->setAttribute('title', 'Potvrdit');
     $form->onSuccess[] = callback($this, 'paymentShippingFormSubmitted');
     return $form;
 }
Exemplo n.º 30
0
 public function createComponentDeliveryPaymentForm()
 {
     $form = new Form();
     $form->onSuccess[] = callback($this, 'deliveryPaymentFormSubmitted');
     $delivery = array();
     $defaultDelivery = null;
     foreach ($this->shop->availableDeliveryMethods as $m) {
         $delivery[$m->id] = $m->name;
         if (!isset($defaultDelivery)) {
             $defaultDelivery = $m->id;
         }
     }
     $form->addRadioList('delivery')->setItems($delivery)->addRule(Form::FILLED, 'Způsob platby musí být vybrán.');
     $defaultDelivery = $this->order->delivery ? $this->order->delivery->id : $defaultDelivery;
     $form['delivery']->setDefaultValue($defaultDelivery);
     $payments = array();
     $defaultPayment = null;
     foreach ($this->shop->availablePaymentMethods as $m) {
         $payments[$m->id] = $m->name;
         if (!isset($defaultPayment) && $this->shop->getDeliveryMethod($defaultDelivery)->isSuitableWith($m)) {
             $defaultPayment = $m->id;
         }
     }
     $form->addRadioList('payment')->setItems($payments)->addRule(Form::FILLED, 'Způsob doručení musí být vybrán.');
     $defaultPayment = $this->order->payment ? $this->order->payment->id : $defaultPayment;
     if (isset($defaultPayment)) {
         $form['payment']->setDefaultValue($defaultPayment);
     }
     $form->addSubmit('back', 'Zpět do košíku')->setValidationScope(false);
     $form->addSubmit('next', 'Pokračovat v objednávce');
     return $form;
 }