Exemple #1
0
 /**
  * Formulář pro registraci uživatele
  * @return Form
  */
 public function createComponentRegistrationForm()
 {
     $form = new Form();
     $form->addText('name', 'Jméno a příjmení:')->setRequired('Je nutné zadat jméno.');
     $form->addText('email', 'E-mail:')->setRequired('Je nutné zadat e-mail')->addRule(Form::EMAIL, 'Je nutné zadat platnou e-mailovou adresu.')->addRule(function (TextInput $input) {
         return !$this->usersModel->findByEmail($input->value);
     }, 'Uživatel s daným e-mailem již existuje.');
     $password = $form->addPassword('password', 'Heslo:')->setRequired('Je nutné zadat heslo.')->addRule(Form::MIN_LENGTH, 'Heslo musí mít minumálně 4 znaky.', 4);
     $form->addPassword('password2', 'Potvrzení hesla:')->addRule(Form::EQUAL, 'Zadaná hesla se neshodují.', $password);
     $form->addSubmit('ok', 'registrovat se')->onClick[] = function (SubmitButton $button) {
         //funkce pro vytvoření nového uživatelského účtu a automatick přihlášení uživatele
         $data = $button->form->getValues(true);
         $user = new User();
         $user->active = true;
         $user->name = $data['name'];
         $user->email = $data['email'];
         $user->password = User::encodePassword($data['password']);
         $user->role = User::DEFAULT_REGISTERED_ROLE;
         if ($this->usersModel->save($user)) {
             $this->flashMessage('Registrace byla úspěšně dokončena.');
             $this->usersModel->sendRegistrationMail($user);
         }
         $this->user->login($data['email'], $data['password']);
         $this->redirect('Homepage:default');
     };
     return $form;
 }
 /**
  * @return Form
  */
 public function create($otherUser = '', $privilegesEdit = false)
 {
     $form = new Form();
     if (!empty($otherUser)) {
         $user = $otherUser;
         $form->addHidden('id', $otherUser->id);
     } else {
         $user = $this->user;
     }
     $form->addUpload('photo', 'Fotka')->addRule($form::MAX_FILE_SIZE, 'Maximální velikost fotky je 10MB', 80000000);
     $form->addText('nickName', 'Přihlašovací jméno')->setValue($user->nickName)->setOption('description', Html::el('p')->setHtml('Pokud chcete můžete pro jednodušší přihlašování zadat jméno'))->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Jméno musí mít alespoň %d znaky', 3);
     $form->addText('name', 'Jméno k zobrazení')->setValue($user->name);
     if ($privilegesEdit) {
         $form->addText('title', 'Titul')->setValue($user->title)->setOption('description', Html::el('p')->setHtml('Titul měnitelný administrátorem přidaný před jméno'));
     }
     $date = $this->parseDateForm();
     $form->addSelect('day', 'Den narození', $date['days'])->setValue($date['day']);
     $form->addSelect('month', 'Měsíc narození', $date['months'])->setValue($date['month']);
     $form->addSelect('year', 'Rok narození', $date['years'])->setValue($date['year']);
     $form->addSelect('gender', 'Pohlaví', ['ma' => 'Muž', 'fe' => 'Žena', 'no' => 'Neuvedeno'])->setValue($user->gender);
     $form->addCheckbox('wall', 'Povolit zeď')->setValue($user->wall == 1 ? true : false);
     $form->addCheckbox('mailList', 'Posílat od nás maily')->setValue($user->mailList == 1 ? true : false);
     $form->addTextArea('about', 'O mě')->setValue($user->about);
     if ($privilegesEdit) {
         $this->editPrivileges($form, $user->permissions);
     }
     $form->addSubmit('submit', 'Uložit');
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     $form->onSuccess[] = [$this, 'formSucceeded'];
     return $form;
 }
 protected function createComponentAddSetting()
 {
     $form = new Form();
     $form->addText('key', 'Klíč')->setRequired('Zadejte klíč nastavení');
     $form->addText('value', 'Hodnota')->setRequired('Zadejte hodnotu nastavení');
     $form->addSubmit('send', 'Zapsat');
     $form->onSuccess[] = function (Form $f) {
         try {
             $val = $f->values;
             $this->settings->set($val->key, $val->value);
             $this->settings->push();
             //Write
             $this->logger->log('System', 'edit', "%user% změnila(a) nastavení");
             $msg = $this->flashMessage("Nastavení bylo zapsáno", 'success');
             $msg->title = 'Yehet!';
             $msg->icon = 'check';
             $this->redirect('this');
         } catch (\PDOException $e) {
             \Nette\Diagnostics\Debugger::log($e);
             $msg = $this->flashMessage("Něco se podělalo. Zkuste to prosím později.", 'danger');
             $msg->title = 'Oh shit!';
             $msg->icon = 'warning';
         }
     };
     return $form;
 }
 /**
  * @return Form
  */
 public function create($role)
 {
     $rights = $this->database->table('rights')->fetchPairs('id', 'name');
     $form = new Form();
     $form->addHidden('id');
     $form->addText('username', 'uživatelské jméno: ')->addRule(Form::FILLED, 'Zadejte prosím jméno.');
     $form->addText('email', 'email: ')->addRule(Form::FILLED, 'Zadejte prosím email.')->addRule(Form::EMAIL, 'Email by měl mít platný formát');
     if (in_array("admin", $role)) {
         // editace prav jen adminem
         $form->addSelect('rights_id', 'level práv: ', $rights);
     }
     $form->addSubmit('submit', 'uložit');
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     //bootstrap vzhled
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = 'div class=form-group';
     $renderer->wrappers['pair']['.error'] = 'has-error';
     $renderer->wrappers['control']['container'] = '';
     $renderer->wrappers['label']['container'] = 'div class="control-label col-sm-5"';
     $renderer->wrappers['control']['description'] = 'span class=help-block';
     $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
     $form->getElementPrototype()->class('form-horizontal col-sm-12');
     return $form;
 }
 /**
  * Contact form
  */
 protected function createComponentContactForm()
 {
     // vytvoříme element
     $products = array('Zakladni' => 'Základní', 'Pokrocile' => 'Pokročilé', 'NaMiru' => 'Na Míru', 'Ostatni' => 'Ostatní');
     $form = new Form();
     $form->addText('name', 'Jméno ')->addRule(Form::FILLED, 'Zadejte jméno');
     $form->addSelect('product', 'Produkt:', $products)->setRequired()->setDefaultValue('Zakladni');
     $form->addText('phone', 'Telefon ');
     $form->addText('email', 'Email')->addRule(Form::FILLED, 'Zadejte email')->addRule(Form::EMAIL, 'Email nemá správný formát');
     $form->addTextarea('message', 'Zpráva', 999, 5)->addRule(Form::FILLED, 'Zadejte zprávu');
     $form->addSubmit('send', 'Odeslat');
     // setup form rendering
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = 'div class=form-group';
     $renderer->wrappers['pair']['.error'] = 'has-error';
     $renderer->wrappers['control']['container'] = 'div class=col-sm-12';
     $renderer->wrappers['label']['container'] = 'div class="col-sm-12  text-center"';
     $renderer->wrappers['control']['description'] = 'span class=help-block';
     $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
     // make form and controls compatible with Twitter Bootstrap
     $form->getElementPrototype()->class('form-horizontal');
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-green btn-block btn-lg' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
     $form->onSuccess[] = $this->processContactForm;
     return $form;
 }
Exemple #6
0
 protected function createComponentPageForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('pageEditForm'));
     $form->getElementPrototype()->id = 'page-form';
     $form->addText('title', 'title.label', null, Page::LENGTH_TITLE)->setMaxLength(Page::LENGTH_TITLE)->setRequired('title.messages.required')->setAttribute('data-text-length', Page::LENGTH_TITLE)->addRule(Form::MAX_LENGTH, new Phrase('title.messages.maxLength', ['numChars' => Page::LENGTH_TITLE]), Page::LENGTH_TITLE);
     $form->addText('publishedAt', 'publishedAt.label', null, 16)->setHtmlId('datetimepicker')->setRequired('publishedAt.messages.required')->addCondition(Form::FILLED)->addRule(Form::MAX_LENGTH, new Phrase('publishedAt.messages.maxLength', ['numChars' => 16]), 16);
     $form->addTextArea('intro', 'intro.label', null, 7)->setMaxLength(Page::LENGTH_INTRO)->setRequired('intro.messages.required')->setAttribute('data-text-length', Page::LENGTH_INTRO)->addRule(Form::MAX_LENGTH, new Phrase('intro.messages.maxLength', ['numChars' => Page::LENGTH_INTRO]), Page::LENGTH_INTRO);
     $form->addTextArea('text', 'text.label', null, 25);
     //->setRequired('text.messages.required');
     $form->addText('url', 'url.label', null, 255);
     $form->addSelect('lang', 'lang.label')->setItems($this->availableLocales)->setDefaultValue($this->defaultLocale);
     if (isset($this->page)) {
         $form['lang']->setDisabled();
         //$form['lang']->setOmitted();
     }
     $form->addCheckbox('allowedComments', 'allowedComments.label')->setDefaultValue(true);
     $form->addText('keywords', 'keywords.label');
     $form->addText('description', 'description.label');
     $form->addSubmit('saveAndPublish', 'saveAndPublish.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAndPublish.title'))->onClick[] = [$this, 'processPageSavingAndPublishing'];
     $form->addSubmit('saveAsDraft', 'saveAsDraft.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAsDraft.title'))->onClick[] = [$this, 'processPageSavingAsDraft'];
     if (!$this->authorizator->isAllowed($this->user, 'page', 'create') or !$this->authorizator->isAllowed($this->user, 'page', 'edit')) {
         $form['saveAndPublish']->setDisabled();
         $form['saveAsDraft']->setDisabled();
     }
     $form->addProtection();
     return $form;
 }
Exemple #7
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;
 }
Exemple #8
0
 /**
  * Register form factory.
  * @return UI\Form
  */
 protected function createComponentSignUpForm()
 {
     $form = new UI\Form();
     $form->setTranslator($this->translator->domain('ui'));
     // 1. Antispam
     $form->addText(self::SPAM1)->setAttribute('style', 'display:none')->addRule(UI\Form::BLANK, 'this-field-should-be-blank');
     // 2. Antispam
     $form->addText(self::SPAM2, self::SPAM2)->setHtmlId('frm-signUpForm-antispam')->setAttribute('data-spam', self::SPAM2)->setRequired(self::SPAM2)->addRule(UI\Form::EQUAL, self::SPAM2, self::SPAM2);
     $form->addText('email2', 'your-email')->setType('email')->setAttribute('placeholder', 'e-g-email-example-com')->addRule(UI\Form::EMAIL, 'please-enter-your-a-valid-email-address-check-for-typos')->setRequired('please-enter-your-a-valid-email-address-check-for-typos')->setAttribute('autofocus');
     $form->addText('fullname', 'how-do-you-want-to-be-called')->setAttribute('placeholder', 'placeholder-fullname')->setRequired('please-choose-how-do-you-want-to-be-called-on-the-web');
     $form->addText('username', 'login-username')->setAttribute('placeholder', 'placeholder-username')->setRequired('please-choose-your-login-username');
     $form->addPassword('password', 'login-password')->setAttribute('placeholder', 'placeholder-password')->setRequired('please-choose-your-login-password')->addRule(UI\Form::MIN_LENGTH, 'please-enter-at-least-d-characters-for-your-password', 8);
     $form->addPassword('passwordVerify', 'confirm-password')->setAttribute('placeholder', 'placeholder-password')->setRequired('please-confirm-your-login-password')->addRule(UI\Form::EQUAL, 'please-check-your-different-password', $form['password']);
     $form->addSubmit('send', 'register');
     $form->onSuccess[] = $this->signUpFormSucceeded;
     $form->getElementPrototype()->role('form');
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
     return $form;
 }
Exemple #9
0
 /**
  * @return \Nette\Application\UI\Form
  */
 public function create()
 {
     $form = new Form();
     $form->addGroup($this->user ? 'Upravit uživatele' : 'Přidat uživatele');
     $form->addText("name", 'Jméno:')->setRequired('Vyplňte jméno');
     $form->addText("email", 'Email:')->setRequired('Vyplňte email')->addRule(function ($ctrl) {
         if ($this->user and $this->user->email == $ctrl->getValue()) {
             return TRUE;
         }
         return (bool) (!$this->userFacade->findUserByEmail($ctrl->getValue()));
     }, 'Email je obsazen, zvolte prosím jiný');
     $password = $form->addPassword("password", 'Heslo:');
     $password2 = $form->addPassword("password2", 'Heslo znovu:');
     if (!$this->user) {
         $password->setRequired('Vyplňte heslo');
         $password2->addRule(Form::FILLED, 'Vyplňte heslo znovu pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $password);
     } else {
         $password2->addConditionOn($password, Form::FILLED)->setRequired('Vyplňte heslo znovu pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $password);
     }
     $form->addSubmit("send", $this->user ? 'Upravit uživatele' : 'Přidat uživatele');
     $form->setRenderer(new Bs3FormRenderer());
     $form->onSuccess[] = $this->processForm;
     if ($this->user) {
         $form->setDefaults(["name" => $this->user->name, "email" => $this->user->email]);
     }
     return $form;
 }
  /**
 * Formular pre editaciu udajov
 * @param boolean $admin
 * @param array $druh
 * @return Nette\Application\UI\Form
 */
  public function create($admin, $druh, $ur_reg)
  {
      $this->ur_reg = $ur_reg;
      $form = new Form();
      $form->addProtection();
      $form->addGroup();
      $form->addHidden('id');
      $form->addHidden('id_udaje_typ');
      if ($admin) {
          $form->addText('nazov', 'Názov prvku:', 20, 20)->addRule(Form::MIN_LENGTH, 'Názov musí mať spoň %d znaky!', 2)->setAttribute('class', 'heading')->setRequired('Názov musí byť zadaný!');
          $form->addText('comment', 'Komentár k hodnote :', 90, 255)->addRule(Form::MIN_LENGTH, 'Komentár musí mať spoň %d znaky!', 2)->setRequired('Komentár musí byť zadaný!');
      } else {
          $form->addHidden('nazov');
          $form->addHidden('comment');
      }
      $form->addText('text', 'Hodnota prvku:', 90, 255)->setRequired('Hodnota prvku musí byť zadaná!');
      if ($admin) {
          $form->addCheckbox('spravca', ' Povolená zmena pre správcu')->setDefaultValue(1);
          $form->addCheckbox("druh_null", " Hodnota druhu je NULL")->setDefaultValue(1)->addCondition(Form::EQUAL, TRUE)->toggle("druh", FALSE);
          $form->addGroup()->setOption('container', Html::el('fieldset')->id("druh"));
          $form->addSelect('id_druh', 'Druhová skupina pre nastavenia:', $druh)->setDefaultValue(1);
          $form->setCurrentGroup(NULL);
Exemple #11
0
 protected function createComponentCourseRegistration()
 {
     $msgNameReq = "Zadejte prosím jméno a příjmení.";
     $msgEmailReq = "Zadejte prosím emailovou adresu.";
     $msgPhoneReq = "Zadejte prosím telefonní číslo.";
     $msgPhoneBad = "Telefon není správně vyplněn.";
     $msgDateReq = "Vyberte prosím termín akce.";
     $persons = array('1 osoba', '2 osoby', '3 osoby', '4 osoby', '5 osob');
     $dates = array();
     foreach ($this->context->parameters['courses'][$this->course]['dates'] as $date) {
         $dates[] = $this->template->date($date['date'], '%d.%m.%Y');
     }
     $form = new Form();
     $form->addText('name', 'Jméno', NULL, 60)->setAttribute('placeholder', 'Jméno a příjmení')->setAttribute('tabindex', 1)->addRule(~$form::EQUAL, $msgNameReq, $form['name']->control->attrs['placeholder'])->setRequired($msgNameReq);
     $form->addText('email', 'Email', NULL, 40)->setAttribute('placeholder', 'Email')->setAttribute('tabindex', 2)->addRule(~$form::EQUAL, $msgEmailReq, $form['email']->control->attrs['placeholder'])->setRequired($msgEmailReq)->addRule(Form::EMAIL, '%label není správně vyplněn.');
     $form->addText('phone', 'Telefon', NULL, 9)->setAttribute('placeholder', 'Telefon')->setAttribute('tabindex', 3)->addRule(~$form::EQUAL, $msgPhoneReq, $form['phone']->control->attrs['placeholder'])->setRequired($msgPhoneReq)->addRule(Form::INTEGER, $msgPhoneBad)->addRule(Form::LENGTH, $msgPhoneBad, 9);
     $form->addSelect('date', 'Termín konání')->setPrompt('Zvolte termín konání')->setItems($dates)->setRequired($msgDateReq);
     if (count($dates) == 1) {
         $form['date']->setDefaultValue(0);
     }
     $form->addSelect('person', 'Počet')->setItems($persons, FALSE);
     $form->addTextArea('note', 'Poznámka', NULL)->setAttribute('placeholder', 'Jakýkoli dotaz nebo zpráva.')->setAttribute('tabindex', 4)->addRule(Form::MAX_LENGTH, 'Poznámka může obsahovat maximálně 1000 znaků.', 1000);
     $form->addSubmit('send', 'Odeslat')->setAttribute('tabindex', 5)->setAttribute('class', 'button');
     $form->addSubmit('storno', 'Storno')->setAttribute('tabindex', 6)->setValidationScope(NULL)->setAttribute('class', 'button');
     $form->addHidden('spamtest')->addRule($form::EQUAL, 'Robot', array(NULL));
     $form->onSuccess[] = callback($this, 'submitRegistration');
     return $form;
 }
Exemple #12
0
 protected function createComponentPageEditor()
 {
     $form = new Form();
     $form->addText('name', 'Název stránky')->setRequired();
     $form->addText('heading', 'Nadpis')->setRequired();
     $form->addTextArea('body', 'Obsah');
     $form->addCheckbox('hidden', 'Výstřižek stránky');
     $form->addHidden('id');
     $form->addSubmit('send', 'Uložit');
     $form->onSuccess[] = function (Form $f) {
         $val = $f->values;
         //Update page
         if ($val->id) {
             $this->pages->find($val->id)->update($val);
             $msg = $this->flashMessage("Stránka byla upravena", 'success');
             $msg->title = 'A je tam!';
             $msg->icon = 'check';
             $this->logger->log('CMS', 'edit', "%user% uprvila(a) stránku {$val->name}");
         } else {
             $r = $this->pages->create($val);
             $msg = $this->flashMessage("Stránka byla vytvořena.", 'success');
             $msg->title = 'A je tam!';
             $msg->icon = 'check';
             $this->redirect('this', ['id' => $r->id]);
             $this->logger->log('CMS', 'create', "%user% vytvořil(a) stránku {$val->name}");
         }
         $this->redirect('this');
     };
     return $form;
 }
Exemple #13
0
 protected function createComponentTagForm()
 {
     $form = new Form();
     $form->addText('title', 'title:')->setRequired()->getControlPrototype()->addClass('form-control');
     $form->addText('slug', 'slug:')->setRequired()->getControlPrototype()->addClass('form-control');
     $form->addText('color', 'color:')->setRequired()->getControlPrototype()->addClass('color {minV:0.9} form-control');
     $form->addText('bg_color', 'bg_color:')->setRequired()->getControlPrototype()->addClass('color {maxV:0.5} form-control');
     $form->addCheckbox('active', 'active:')->setRequired()->getControlPrototype()->addClass('form-control');
     $form->addSubmit('send', 'Save tag')->getControlPrototype()->setName('button')->addClass('btn btn-success')->setHtml('<span class="glyphicon glyphicon-ok"></span>');
     $form->onSuccess[] = array($this, 'tagFormSucceeded');
     // setup form rendering
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['pair']['container'] = 'div class=form-group';
     $renderer->wrappers['pair']['.error'] = 'has-error';
     $renderer->wrappers['control']['container'] = 'div class=col-sm-10';
     $renderer->wrappers['label']['container'] = 'div class="col-sm-2 control-label"';
     $renderer->wrappers['control']['description'] = 'span class=help-block';
     $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
     // make form and controls compatible with Twitter Bootstrap
     $form->getElementPrototype()->class('form-horizontal');
     // <form class="form-horizontal">
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
     return $form;
 }
Exemple #14
0
 protected function createComponentVytvoritForm()
 {
     $form = new Form();
     //Zivocich
     $hodnotyZivocich = array();
     $zivocichy = $this->database->table('zivocich');
     //ziskam si vsetkych zivocichov
     foreach ($zivocichy as $zivocich) {
         $hodnotyZivocich[$zivocich->IDZivocicha] = $zivocich->meno;
     }
     $form->addSelect('IDZivocicha', '*Živočích:', $hodnotyZivocich)->setRequired();
     //Zamestnanec
     $hodnotyZamestnancov = array();
     if ($this->getUser()->roles[0] == 'riaditeľ') {
         $zamestnanci = $this->database->table('zamestnanec');
         //ziskam si vsetkych zamestnancov
         foreach ($zamestnanci as $zamestnanec) {
             $hodnotyZamestnancov[$zamestnanec->RodneCislo] = $zamestnanec->meno . " " . $zamestnanec->priezvisko;
         }
     } else {
         $hodnotyZamestnancov[$this->getUser()->id] = $this->getUser()->getIdentity()->data['meno'];
     }
     $form->addSelect('RodneCislo', '*Zamestnanec:', $hodnotyZamestnancov)->setRequired();
     $form->addText('hmotnostZivocicha', 'Hmotnosť živočícha:')->addCondition(Form::FILLED)->addRule(Form::FLOAT, 'Pole musi obsahovať iba čísla!');
     $form->addText('rozmerZivocicha', 'Rozmer živočícha:')->addCondition(Form::FILLED)->addRule(Form::FLOAT, 'Pole musi obsahovať iba čísla!');
     $form->addText('datumTestu', '*Dátum testu(YYYY-MM-DD):')->setRequired()->addRule(Form::PATTERN, 'Nesprávny fomrát', '([0-9]){4}-([0-9]){2}-([0-9]){2}');
     $form->addSubmit('vytvorit', 'Vytvoriť');
     $form->onSuccess[] = array($this, 'uspesne');
     $form->setRenderer(new Bs3FormRenderer());
     return $form;
 }
 /**
  * @return \Nette\Application\UI\Form
  */
 protected function createForm()
 {
     $form = new Form();
     $form->addText('code', 'Kód')->addRule(Form::FILLED, "Vyplňte prosím kód");
     $form->addText('name', 'Název')->addRule(Form::FILLED, "Vyplňte prosím název");
     $form->addSubmit('save', 'Uložit');
     return $form;
 }
Exemple #16
0
 /**
  * @return Form
  */
 public function create()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('tags.tagForm'));
     $form->addText('name', 'name.label', null, Tag::LENGTH_NAME)->setRequired('name.messages.required');
     $form->addText('color', 'color.label', null, 7)->setRequired('color.messages.required')->setDefaultValue('#')->addRule(Form::PATTERN, 'color.messages.wrongPattern', '^#([0-f]{3}|[0-f]{6})$');
     $form->addSubmit('save', 'save.caption');
     return $form;
 }
 protected function createComponentItemForm()
 {
     $form = new UI\Form();
     $form->addText('email', 'Email:')->addRule($form::EMAIL, 'Email není ve správném tvaru.')->setRequired();
     $form->addText('password', 'Heslo:')->addRule($form::MIN_LENGTH, 'Minimální délka hesla je 6 znaků.', 6);
     $form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary');
     $form->onSuccess[] = array($this, 'itemFormSucceeded');
     return $form;
 }
 /**
  * @Actions application
  */
 protected function createComponentInvitationApplication()
 {
     $form = new Form();
     $form->addText('email', 'E-mail svázaný s pozvánkou')->setRequired('Vyplňte prosím pole pro E-mail.')->addRule(Form::EMAIL, 'Zadejte E-mailovou adresu ve správném formátu');
     $form->addText('token', 'Registrační kód pozvánky', null, Invitation::TOKEN_LENGTH)->setRequired('Zadejte registrační kód');
     $form->addSubmit('send', 'Zkontrolovat pozvánku')->setHtmlId('invitation-process-button');
     $form->onSuccess[] = [$this, 'processInvitation'];
     return $form;
 }
Exemple #19
0
 protected function createComponentInitForm()
 {
     $form = new Form();
     $form->addText('appKey', 'Dropbox App Key')->setRequired();
     $form->addText('appSecret', 'Dropbox App Secret')->setRequired();
     $form->addSubmit('submit');
     $form->onSuccess[] = array($this, 'initFormSucceeded');
     return $form;
 }
Exemple #20
0
 protected function createComponentFormAdd()
 {
     $form = new Form();
     $form->addText('type', 'Type')->setDefaultValue('vcs')->setRequired();
     $form->addText('url', 'Url')->setRequired();
     $form->addSubmit('btnSubmit', 'Add');
     $form->onSuccess[] = $this->addPackage;
     return $form;
 }
Exemple #21
0
 public function create()
 {
     $form = new Form();
     $form->addText('title', 'Napis')->setRequired('Musíte zadat titulek');
     $form->addTextArea('text', 'Text')->setRequired('Musíte zadat text');
     $form->addText('keyWords', 'Klíčová slova');
     $form->addSubmit('submit', 'Odeslat');
     return $form;
 }
Exemple #22
0
 /**
  * Contact form
  */
 protected function createComponentContactForm()
 {
     $form = new Form();
     $form->addText('name', 'Jméno:')->addRule(Form::FILLED, 'Zadejte jméno');
     $form->addText('email', 'Email:')->addRule(Form::FILLED, 'Zadejte email')->addRule(Form::EMAIL, 'Email nemá správný formát');
     $form->addTextarea('message', 'Zpráva:')->addRule(Form::FILLED, 'Zadejte zprávu');
     $form->addSubmit('send', 'Odeslat');
     $form->onSuccess[] = $this->processContactForm;
     return $form;
 }
Exemple #23
0
 /**
  * @return Form
  */
 protected function createComponentInsertTaskForm()
 {
     $form = new Form();
     $form->addText('name', 'Name')->setRequired('Please fill task name');
     $form->addText('date', 'Date')->setRequired('Please fill task date');
     $form->addHidden('idTaskGroup', $this->idTaskGroup);
     $form->addSubmit('submit', 'Add');
     $form->onSuccess[] = array($this, 'insertTaskFromSuccess');
     return $form;
 }
 /**
  * Edit form factory.
  * @return Form
  */
 protected function createComponentAlbumForm()
 {
     $form = new Form();
     $form->addText('artist', 'Artist:')->setRequired('Please enter an artist.');
     $form->addText('title', 'Title:')->setRequired('Please enter a title.');
     $form->addSubmit('save', 'Save')->setAttribute('class', 'default')->onClick[] = [$this, 'albumFormSucceeded'];
     $form->addSubmit('cancel', 'Cancel')->setValidationScope([])->onClick[] = [$this, 'formCancelled'];
     $form->addProtection();
     return $form;
 }
Exemple #25
0
 /**
  * @return Form
  */
 public function createComponentForm()
 {
     $form = new UI\Form();
     $form->addText('email', 'E-mail:')->setRequired('Please enter your email.');
     $form->addText('name', 'Name:')->setRequired('Please enter your name.');
     $form->addPassword('password', 'Password:'******'Please enter your password.');
     $form->addSubmit('send', 'Sign up');
     $form->onSuccess[] = array($this, 'formSucceeded');
     return $form;
 }
Exemple #26
0
 protected function createComponentRegistraceForm()
 {
     $form = new Form();
     $form->addText('name', 'Jméno')->setRequired("Jméno je povinné")->addRule(Form::MIN_LENGTH, 'Jméno musí mít minimálně %d znaků', 5)->addRule(Form::MAX_LENGTH, 'Maximalni delka je %d znaků', 150);
     $form->addText('email', 'E-mail')->setRequired("Jméno je povinné")->addRule(Form::MAX_LENGTH, 'Maximalni delka je %d znaků', 100)->addRule(Form::EMAIL, 'Váš email nebyl zadán spávně.');
     $form->addPassword('password', 'Heslo:')->setRequired("Heslo je povinne")->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaky', 6)->addRule(Form::MAX_LENGTH, 'Maximalni delka je %d znaků', 100);
     $form->addSubmit('send', 'Registrovat se');
     $form->onSuccess[] = array($this, 'commentFormSucceeded');
     return $form;
 }
 protected function createComponentEnterCode()
 {
     $form = new Form();
     $form->addText('mail', 'Mail:')->setDisabled(true)->setValue($this->user->getIdentity()->mail);
     $form->addText('checkCode', 'Kontrolní kód z mailu');
     $form->addSubmit('check', 'Zkontrolovat potvrzovací kód');
     $form->addSubmit('cancl', 'Začít znova');
     $form->onSuccess[] = [$this, 'enterCodeSucceeded'];
     return $form;
 }
Exemple #28
0
 protected function createComponentCreateMessageForm()
 {
     $form = new Nette\Application\UI\Form();
     $form->addText('name', 'For: ')->setRequired();
     $form->addText('title', 'Title: ')->setRequired();
     $form->addTextArea('content', 'Content:')->setRequired();
     $form->addSubmit('send', 'Create');
     $form->onSuccess[] = $this->createMessageFormSucceeded;
     return $form;
 }
Exemple #29
0
 protected function createComponentEmailForm()
 {
     $form = new Form();
     $form->addText('email', 'Váš email')->addRule(Form::EMAIL, 'Prosím, zadejte platný email.');
     $form->addText('name', 'Vaše jméno')->setRequired('Prosím, zadejte vaše jméno.');
     $form->addTextArea('message', 'Zpráva')->addRule(Form::MIN_LENGTH, 'Zpráva je příliš krátká.', 5);
     $form->addSubmit('send', 'Odeslat');
     $form->onSuccess[] = array($this, 'emailFormSucceeded');
     $form->onValidate[] = array($this, 'validateEmailForm');
     return $form;
 }
 protected function createComponentFormRegister()
 {
     $form = new Form();
     $form->addText('nick', 'Nick')->setRequired()->addRule(Form::MIN_LENGTH, 'Nick must be at least %d characters long', 4);
     $form->addText('email', 'Email')->setRequired()->addRule(Form::EMAIL);
     $form->addPassword('password', 'Password')->setRequired();
     $form->addCheckbox('show_password', 'Show password');
     $form->addSubmit('btnSubmit', 'Register');
     $form->onSuccess[] = callback($this, 'formRegisterSubmitted');
     return $form;
 }