本文整理汇总了PHP中Nette\Application\UI\Form::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getValues方法的具体用法?PHP Form::getValues怎么用?PHP Form::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchForGroupFormSubmitted
public function searchForGroupFormSubmitted(Form $form)
{
$query = $form->getValues();
$this->groupsOutput = $this->groupModel->findAllByName($query->name);
$this->searchInput = $query->name;
$this->template->groupsOutput = $this->groupsOutput == null;
}
示例2: signupFormSubmitted
/**
*
* @param Nette\Application\UI\Form $form
*/
public function signupFormSubmitted(Form $form)
{
$formValues = $form->getValues();
$userUsernameRow = $this->userFacade->getByUsername($formValues->username);
$userEmailRow = $this->userFacade->getByEmail($formValues->email);
if ($userUsernameRow !== false || $userEmailRow !== false) {
if ($userUsernameRow !== false) {
$form['username']->addError('This username is already taken. Please use different one.');
}
if ($userEmailRow !== false) {
$form['email']->addError('This email is already taken. Please use different one.');
}
} else {
$hashedPassword = \Screwfix\Authenticator::calculateHash($formValues->password);
$userArr = array('username' => $formValues->username, 'role' => 'member', 'email' => $formValues->email, 'password' => $hashedPassword);
try {
$this->userFacade->save($userArr);
$user = $this->getUser();
if ($formValues->remember) {
$user->setExpiration('+14 days', FALSE);
}
$user->login($formValues->username, $formValues->password);
$pattern = $this->adjustPattern($formValues->patternInput['pattern'], $formValues->patternInput['firstDay']);
$patternFilter = $this->shiftPatternFilterFactory->create($pattern);
$this->patternFacade->save($user->getId(), $patternFilter);
} catch (\Exception $ex) {
$form->addError('Sorry, something went wrong. Please try again.');
}
$this->redirect('Home:default');
}
}
示例3: formSucceeded
public function formSucceeded(Form $form)
{
try {
$p = $this->getPresenter();
$values = $form->getValues();
if (strlen($values->__anti) > 0) {
throw new FormSentBySpamException($this->translator->translate('locale.form.spam_attempt_sign_up'));
}
unset($values->__anti);
$user = $this->userRepository->createRegistration($values);
$link = $p->link('//:Admin:Sign:unlock', array('uid' => $user->id, 'token' => $user->token));
$this->sendEmail($this->contactEmail, $user->email, $this->translator->translate('locale.sign.sign_up_request'), $link);
$p->flashMessage($this->translator->translate('locale.sign.sign_up_email_sent'), FlashType::SUCCESS);
} catch (FormSentBySpamException $e) {
$this->addFormError($form, $e);
$this->redrawControl('formErrors');
} catch (PossibleUniqueKeyDuplicationException $e) {
$this->addFormError($form, $e);
$this->redrawControl('formErrors');
} catch (\Exception $e) {
$this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
$this->redrawControl('formErrors');
}
if (!empty($user)) {
$p->redirect('Homepage:default');
}
}
示例4: processUserRegistration
public function processUserRegistration(Form $form)
{
$values = $form->getValues();
$forbiddenNames = array_flip(['systém', 'system', 'admin', 'administrator', 'administrátor']);
if (array_key_exists(strtolower($values['username']), $forbiddenNames)) {
$form->addError('Vámi zadané jméno nelze použít. Vyberte si prosím jiné.');
return;
}
$values['ip'] = $this->getHttpRequest()->getRemoteAddress();
$values['role'] = 'employee';
$user = new User($values['username'], $values['password'], $values['email'], $values['ip'], $this->invitation->getSender(), $values['role']);
try {
$this->usersFacade->registerNewUser($user, $this->invitation);
$this->flashMessage('Váš účet byl vytvořen. Nyní se můžete přihlásit.', 'success');
$this->redirect('Login:default');
} catch (InvitationValidityException $iu) {
$this->flashMessage('Registrovat se může pouze uživatel s platnou pozvánkou.', 'warning');
$this->redirect('Login:default');
} catch (InvalidUserInvitationEmailException $iue) {
$form->addError('Nesouhlasí Vámi zadaný E-mail a E-mail vázaný na pozvánku.');
} catch (\Exceptions\Runtime\DuplicateUsernameException $du) {
$form->addError('Vámi zvolené jméno využívá již někdo jiný. Vyberte si prosím jiné jméno.');
} catch (\Exceptions\Runtime\DuplicateEmailException $de) {
$this->flashMessage('E-mail svázaný s pozvánkou využívá již jeden z registrovaných
uživatelů. Nechte si zaslat novou pozvánku s jinou E-mailovou adresou.', 'warning');
$this->redirect('Login:default');
} catch (DBALException $d) {
$form->addError('Registraci nelze dokončit. Zkuste to prosím později.');
}
}
示例5: formSucceeded
public function formSucceeded(Form $form)
{
try {
$p = $this->getPresenter();
$values = $form->getValues();
$tag = $this->getSelectedTag($form);
if ($this->item) {
$ent = $this->videoRepository->update($values, $tag, $this->user, $this->item);
$p->flashMessage($this->translator->translate('locale.item.updated'));
} else {
$ent = $this->videoRepository->create($values, $tag, $this->user, new Entities\VideoEntity());
$p->flashMessage($this->translator->translate('locale.item.created'));
}
} catch (Exceptions\MissingTagException $e) {
$this->addFormError($form, $e);
} catch (PossibleUniqueKeyDuplicationException $e) {
$this->addFormError($form, $e);
} catch (InvalidVideoUrlException $e) {
$this->addFormError($form, $e);
} catch (\Exception $e) {
$this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
}
if (!empty($ent)) {
$p->redirect('this');
}
}
示例6: formEditSave
/**
* Process a directive edit form.
* @param void
*/
public function formEditSave(Form $form)
{
$data = $form->getValues();
$this->id = $data->id;
$this->title = $data->title;
$this->date = $data->date;
$this->change = $data->change;
$this->revision = $data->revision;
$oldName = $this->document;
$this->setDocument();
try {
$this->row->update(array('id' => $this->id, 'title' => $this->title, 'date' => $this->date, 'change' => $this->change, 'revision' => $this->revision, 'document' => $this->document));
if ($oldName) {
$this->renameDocFile($oldName, $this->document);
}
foreach ($this->getComponents(FALSE, "Annex") as $annex) {
$annex->id = $this->id;
$annex->updateData();
}
$this->presenter->flashMessage('Směrnice byla aktualizována.', 'success');
$this->redirect('this');
} catch (Nette\Application\AbortException $e) {
throw $e;
} catch (Exception $ex) {
if ($ex->getCode() == 23000) {
$this->presenter->flashMessage('Zadané číslo směrnice již existuje. ', 'error');
$this->handleEdit();
}
}
}
示例7: formSucceeded
public function formSucceeded(Form $form)
{
try {
$p = $this->getPresenter();
$values = $form->getValues();
if (strlen($values->__anti) > 0) {
throw new FormSentBySpamException($this->translator->translate('locale.form.spam_attempt_sign_reset'));
}
unset($values->__anti);
$user = $this->userRepository->getByEmail($values->email);
if (!$user) {
throw new UserNotFoundException();
}
$token = $this->userRepository->prepareNewToken($user);
$link = $p->link('//:Admin:Sign:password', array('uid' => $user->id, 'token' => $token));
$this->sendEmail($this->contactEmail, $values->email, $this->translator->translate('locale.sign.new_password_request'), $link);
$p->flashMessage($this->translator->translate('locale.sign.new_password_request_email_sent'), FlashType::INFO);
} catch (FormSentBySpamException $e) {
$this->addFormError($form, $e);
$this->redrawControl('formErrors');
} catch (UserNotFoundException $e) {
$this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
$this->redrawControl('formErrors');
} catch (\PDOException $e) {
$this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
$this->redrawControl('formErrors');
}
$p->redirect(':Front:Homepage:default');
}
示例8: formSucceeded
public function formSucceeded(Form $form)
{
try {
$p = $this->getPresenter();
$values = $form->getValues();
$latest = $this->wikiDraftRepository->getLatestByWiki($this->item);
$start = DateTime::from($values->startTime);
if ($latest && $start < $latest->createdAt) {
throw new Exceptions\WikiDraftConflictException($this->translator->translate('locale.error.newer_draft_created_meanwhile'));
}
unset($values->name);
unset($values->startTime);
$this->wikiDraftRepository->create($values, $this->user, $this->item, new Entities\WikiDraftEntity());
$ent = $this->item;
$p->flashMessage($this->translator->translate('locale.item.updated'));
} catch (Exceptions\WikiDraftConflictException $e) {
$this->newerDraftExists = true;
$this->addFormError($form, $e);
} catch (Exceptions\MissingTagException $e) {
$this->addFormError($form, $e);
} catch (PossibleUniqueKeyDuplicationException $e) {
$this->addFormError($form, $e);
} catch (\Exception $e) {
$this->addFormError($form, $e, $this->translator->translate('locale.error.occurred'));
}
if (!empty($ent)) {
$p->redirect('this');
}
}
示例9: signInFormSucceeded
/**
*
* @param Nette\Application\UI\Form $form
* @throws \Exception
*/
public function signInFormSucceeded($form)
{
$values = $form->getValues();
if ($values->remember) {
$this->user->setExpiration('14 days', FALSE);
} else {
$this->user->setExpiration('20 minutes', TRUE);
}
try {
$user = $this->getActiveUserByUsername($values->username);
if (!$user) {
throw new \Exception('Uživatel není aktivní nebo neexistuje.');
}
$this->user->login($user->username, $values->password);
$this->flashMessage('Byl/a jste úspěšně přihlášen/a jako "' . $user->username . '"', 'success');
if (!empty($values['backSignInUrl'])) {
$redirectToUrl = $values['backSignInUrl'];
} else {
$this->redirect('Homepage:');
}
} catch (Nette\Security\AuthenticationException $e) {
$form->addError($e->getMessage());
} catch (\Exception $e) {
$form->addError($e->getMessage());
}
if (!empty($redirectToUrl)) {
$this->redirectUrl($redirectToUrl);
}
}
示例10: formSubmitted
/**
* @param \Nette\Application\UI\Form $form
*/
public function formSubmitted(Form $form)
{
$values = $form->getValues();
$this->getPaginator()->setDate($values['paginatorDate']);
$this->date = $values['paginatorDate']->format('Y-m-d');
$this->redirect('this', array('date' => $this->date));
}
示例11: Submit
/** Submit
* @param Form $form
*/
public function Submit(Form $form)
{
$values = $form->getValues();
$contactEntity = new ContactEntity();
$userEntity = new UserEntity();
$contactEntity->setValues((array) $values);
$userEntity->setLogin($values->login);
$userEntity->setAclRoleID(10);
// guest role
$userEntity->setPassword($values->password);
$userEntity->setActive(TRUE);
$contactEntity->setUser($userEntity);
try {
$this->contactRepository->push($contactEntity);
$result = $this->contactRepository->save();
if ($result) {
$this->flashMessage("Vaše registrace proběhla úspěšně.");
$this->redirect('this');
} else {
$form->addError("Vaše registrace neproběhla úspěšně.");
}
} catch (\PDOException $e) {
if (strpos($e->getMessage(), "1062 Duplicate entry") !== FALSE) {
$form->addError("Uživatel {$values->login} již existuje. Zvolte si prosím jiný přihlašovací email.");
} else {
$form->addError($e->getMessage());
}
}
}
示例12: addToBasketSubmitted
public function addToBasketSubmitted(Form $form)
{
$values = $form->getValues();
$this->basketService->getBasket()->addItem($values->itemId, 1);
$this->flashMessage('Zboží bylo přídáno do košíku.');
$this->redirect('this');
}
示例13: processCreateInvitation
public function processCreateInvitation(Form $form)
{
$value = $form->getValues();
$invitation = new Invitation($value['email'], $this->user->getIdentity());
try {
/** @var EntityResultObject $resultObject */
$resultObject = $this->invitationsFacade->createInvitation($invitation);
$this->flashMessage('Registrační pozvánka byla vytvořena.', 'success');
if (!$resultObject->hasNoErrors()) {
$error = $resultObject->getFirstError();
$this->flashMessage($error['message'], $error['type']);
}
} catch (InvitationCreationAttemptException $ca) {
$this->flashMessage('Pozvánku nebyla vytvořena. Zkuste akci opakovat později.', 'error');
} catch (UserAlreadyExistsException $uae) {
$form->addError('Pozvánku nelze odeslat. Uživatel s E-Mailem ' . $value['email'] . ' je již zaregistrován.');
return;
} catch (InvitationAlreadyExistsException $iae) {
$form->addError('Někdo jiný již odeslal pozvánku uživateli s E-mailem ' . $value['email']);
return;
} catch (DBALException $e) {
$this->flashMessage('Při vytváření pozvánky došlo k chybě. Zkuste akci opakovat později.', 'error');
}
$this->redirect('this');
}
示例14: processRegister
/**
* @param \Nette\Application\UI\Form $form
*/
public function processRegister(\Nette\Application\UI\Form $form)
{
$values = $form->getValues();
if ($this->userRepository->existsUsername($values->username)) {
$form["username"]->addError($this->t("forms.register.errors.exists-username"));
} else {
if ($this->userRepository->existsEmail($values->email)) {
$form["email"]->addError($this->t("forms.register.errors.exists-email"));
} else {
$this->getDbUtils()->begin();
try {
$registerOptions = $this->container->getParameters()["register"];
if ($registerOptions["activation"]) {
$status = \Model\Common\RecordStatus::UNFINISHED;
} else {
$status = \Model\Common\RecordStatus::VALID;
}
$user = $this->userRepository->createNewUser($values, $registerOptions["defaultGroupId"], $status);
if ($registerOptions["activation"]) {
$this->sendActivationEmail($values->email, $user);
$this->flashMessage($this->t("forms.register.messages.need-activate"), "info");
} else {
$this->flashMessage($this->t("forms.register.messages.register-success"), "success");
}
$form->setDefaults(array("username" => "", "email" => ""), TRUE);
$this->getDbUtils()->commit();
} catch (\Exception $e) {
$this->getDbUtils()->rollback();
$this->catchFormError($e, $form, $this->t("global.errors.database-error"));
}
}
}
$this->redrawControl("registerForm");
}
示例15: signInFormSubmitted
public function signInFormSubmitted(Form $form)
{
try {
$user = $this->getUser();
$values = $form->getValues();
/*if ($values->persistent) {
$user->setExpiration('+30 days', FALSE);
}*/
/** make login */
$user->login($values->username, $values->password);
/** get rights */
$userId = $user->getIdentity()->id;
$permissions = array();
foreach ($this->permissionRepository->getLevels($userId)->fetchPairs('url') as $page => $level) {
$permissions[$page] = $level->level;
}
/** test for admin */
$permissions['admin'] = $this->userRepository->isAdmin($userId);
/** set permissions */
$user->getIdentity()->setRoles($permissions);
$this->flashMessage('Přihlášení bylo úspěšné.', 'success');
$this->redirect('Homepage:');
} catch (Nette\Security\AuthenticationException $e) {
$form->addError('Neplatné uživatelské jméno nebo heslo.');
}
}