Esempio n. 1
0
 /**
  * @return \Nette\Application\UI\Form
  */
 protected function createForm()
 {
     $form = new Form();
     $base = $form->addContainer('base');
     $password = $form->addContainer('password');
     $elections = $form->addContainer('elections');
     $base->addText('username', 'Uživatelské jméno')->addRule(Form::FILLED, "Vyplňte prosím uživatelské jméno");
     $base->addTextNull('name', 'Jméno')->addRule(Form::FILLED, "Vyplňte prosím jméno");
     $base->addTextNull('surname', 'Příjmení')->addRule(Form::FILLED, "Vyplňte prosím příjmení");
     $base->addText('email', 'Email')->setRequired()->addRule(Form::EMAIL, "Zadejte prosím validní emailovou adresu.");
     $password->addTextNull('password', 'Heslo')->setType('password')->setAttribute('autocomplete', 'off')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Zadané heslo je příliš krátké, zvolte si heslo alespoň o %d znacích', 8);
     $password->addPassword('passwordCheck', 'Heslo pro kontrolu')->setOmitted()->setAttribute('autocomplete', 'off')->addConditionOn($password['password'], Form::FILLED)->addRule(Form::EQUAL, 'Heslo pro kontrolu se neshoduje', $password['password']);
     $elections['role'] = $this->roleFormItemFactory->create();
     $elections['role']->addRule(Form::FILLED, "Přiřaďte prosím uživateli roli");
     $elections['section'] = $this->sectionFormItemFactory->createMultiselectBox();
     $form->addSubmit('save', 'Uložit');
     $form->onValidate[] = function (Form $form) {
         $this->checkUsername($form);
     };
     $form->onValidate[] = function (Form $form) {
         $this->checkNewUserPassword($form);
     };
     $form->onValidate[] = function (Form $form) {
         $this->checkSectionBindins($form);
     };
     return $form;
 }
Esempio n. 2
0
 protected function createForm()
 {
     $form = new Form();
     if ($this->isFrontSection()) {
         $form->addContainer('section')['section'] = $this->sectionFormItemFactory->createMultiselectBox();
     }
     $base = $form->addContainer('base');
     $base->addTextNull('name', 'Název');
     $base->addCheckbox('show', 'Zobrazit')->setDefaultValue(TRUE);
     $base->addTextAreaNull('content', 'Obsah stránky')->setAttribute('class', 'mceEditorSimple');
     $form->addSubmit('save', 'Uložit');
     return $form;
 }