/** * @return Nette\Application\UI\Form */ protected function createComponentTaskForm() { $userPairs = $this->users->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; }
/** * @param Nette\Application\UI\Form $form */ public function passwordFormSubmitted(Form $form) { $values = $form->getValues(); $user = $this->getUser(); try { $this->authenticator->authenticate(array($user->getIdentity()->username, $values->oldPassword)); $this->users->setPassword($user->getId(), $values->newPassword); $this->flashMessage('Heslo bylo změněno.', 'success'); $this->redirect('Homepage:'); } catch (NS\AuthenticationException $e) { $form->addError('Zadané heslo není správné.'); } }