Ejemplo n.º 1
0
 /**
  * @return Nette\Application\UI\Form
  */
 protected function createComponentTaskForm()
 {
     $userPairs = $this->userRepository->findAll()->fetchPairs('id', 'name');
     $form = new Form();
     $form->addText('text', 'Úkol:', 40, 100)->addRule(Form::FILLED, 'Je nutné zadat text úkolu.');
     $form->addSelect('userId', 'Pro:', $userPairs)->setPrompt('- Vyberte -')->addRule(Form::FILLED, 'Je nutné vybrat, komu je úkol přiřazen.')->setDefaultValue($this->getUser()->getId());
     $form->addSubmit('create', 'Vytvořit');
     $form->onSuccess[] = $this->taskFormSubmitted;
     return $form;
 }
Ejemplo n.º 2
0
 public function passwordFormSubmitted(Form $form)
 {
     $values = $form->getValues();
     $user = $this->getUser();
     try {
         $this->authenticator->authenticate(array($user->getIdentity()->username, $values->oldPassword));
         $this->userRepository->setPassword($user->getId(), $values->newPassword);
         $this->flashMessage('Heslo bylo změněno.', 'success');
         $this->redirect('Homepage:');
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError('Zadané heslo není správné.');
     }
 }