Ejemplo n.º 1
0
 /**
  * User form factory.
  *
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentUserForm()
 {
     $userRoleArray = $this->mainManager->findUserRoles($this->getUser());
     $form = BaseFormRenderer::factory();
     $form->addText('username', 'Username:'******'Please enter username.');
     $password = $form->addPassword('password', 'Password:'******'class', 'b-password-input--with-strength')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Password min length is %d chars', 6);
     if (!$this->detailObject) {
         $password->setRequired('Please enter password.');
     }
     $form->addText('email', 'E-mail:')->setRequired('Please enter e-mail.')->addRule(Form::EMAIL, 'This is not valid e-mail.');
     $form->addText('name', 'Name:');
     $form->addUpload('avatar', 'Avatar:')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'Please select image file');
     $form->addSelect("role", "User role:", $userRoleArray)->setRequired('Select user role.');
     if ($this->detailObject) {
         $form->addHidden('id');
         $form->setDefaults($this->detailObject);
     } else {
         $form->addCheckbox("sendInstructions", "Send instructions?");
     }
     $form->addSubmit('send', $this->detailObject ? 'Save user' : 'Add user');
     $form->onSuccess[] = $this->objectFormSucceeded;
     return $form;
 }