Beispiel #1
0
 public function formSucceeded(Form $form, $values)
 {
     if ($values->remember) {
         $this->user->setExpiration('14 days', FALSE);
     } else {
         $this->user->setExpiration('20 minutes', TRUE);
     }
     try {
         $this->user->login($values->email, $values->password);
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError($form->translate('errors.wrong_login'));
     }
 }
 /**
  * 
  * @param integer $id
  * @return Form
  */
 public function editInfo($id)
 {
     $this->user_id = $id;
     $user = $this->user_manager->getUser($id);
     $form = new Form();
     $form->enableLocalized();
     $form->addText('name')->setValue($user->name)->setRequired('errors.fill_user_name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'user_name');
     $form->addText('email')->setValue($user->email)->setRequired('errors.fill_email')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'email')->addRule(Form::EMAIL, 'errors.fill_email_success')->addRule($this->checkEmailUpdate, 'errros.email_used');
     $form->addSelect('role', $form->translate('role'), $this->getListRoles())->setAttribute('class', 'form-control')->setValue($user->user_roles_id)->setRequired('errors.field_required')->setTranslator(null);
     $form->addUpload('img')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'user_name')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'errors.img');
     $form->addSubmit('submit', 'edit')->setAttribute('class', 'btn btn-primary btn-purple btn-flat');
     $form->onSuccess[] = $this->success_form_info;
     return $form;
 }
Beispiel #3
0
 public function create()
 {
     $form = new Form();
     $form->enableLocalized();
     $form->addText('username')->setRequired('errors.fill_user_name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'user_name');
     $form->addUpload('img')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'img')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'errors.img');
     $form->addText('email')->setRequired('errors.fill_email')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'email')->addRule(Form::EMAIL, 'errors.fill_email_success')->addRule($this->checkEmail, 'errors.email_used');
     $form->addSelect('role', $form->translate('role'), $this->getRoleList())->setRequired('errors.role')->setTranslator(null)->setAttribute('class', 'form-control');
     $form->addPassword('password')->setRequired('errors.enter_password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'password');
     $form->addPassword('password2')->setRequired('errors.enter_password_retry')->setAttribute('class', 'form-control')->addRule(Form::EQUAL, 'errors.password_must_match', $form['password'])->setAttribute('placeholder', 'password_retry');
     $form->addSubmit('submit', 'register')->setAttribute('class', 'btn btn-primary btn-purple btn-flat');
     $form->onSuccess[] = $this->success_form_add;
     return $form;
 }