本文整理汇总了PHP中Nette\Forms\Form::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addError方法的具体用法?PHP Form::addError怎么用?PHP Form::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::addError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formSuccess
public function formSuccess(Form $form, $values)
{
$t = $this->getTranslator();
try {
$this->user->login($values->login, $values->password);
$this->fireEvent('onLogin', [$this->user->id]);
//$this->onLogin($this->user->id);
$this->presenter->redirect('this');
} catch (ZaxCMS\Security\UserLoginDisabledException $ex) {
$form->addError($t->translate('auth.error.loginDisabled'));
} catch (ZaxCMS\Security\InvalidCredentialsException $ex) {
if ($this->groupLoginPasswordErrors) {
$form['login']->addError('');
$form['password']->addError($t->translate('auth.error.invalidCredentials'));
} else {
if ($ex instanceof ZaxCMS\Security\InvalidEmailException) {
$form['login']->addError($t->translate('auth.error.invalidEmail'));
} else {
if ($ex instanceof ZaxCMS\Security\InvalidNameException) {
$form['login']->addError($t->translate('auth.error.invalidName'));
} else {
if ($ex instanceof ZaxCMS\Security\InvalidPasswordException) {
$form['password']->addError($t->translate('auth.error.invalidPassword'));
}
}
}
}
} catch (ZaxCMS\Security\UnverifiedUserException $ex) {
$form->addError($t->translate('auth.error.unverifiedUser'));
} catch (ZaxCMS\Security\BannedUserException $ex) {
$form->addError($t->translate('auth.error.bannedUser'));
} catch (ZaxCMS\Security\AuthenticationException $ex) {
$this->onError($ex);
}
}
示例2: loginFormSucceded
public function loginFormSucceded(Form $form, $values)
{
$settings = $this->EntityManager->getRepository(Settings::getClassName());
$setting = $settings->find(1);
if ($setting->admin_login == $values['login'] and $setting->admin_pass == md5($values['pass'])) {
$this->getUser()->login($setting->admin_login, $setting->admin_pass);
$this->redirect('Homepage:');
} else {
$form->addError('Špatně zadaný login nebo heslo!');
}
}
示例3: pageSaving
private function pageSaving(\Nette\Forms\Form $form, $isDraft)
{
if (!$this->authorizator->isAllowed($this->user, 'page', 'create') or !$this->authorizator->isAllowed($this->user, 'page', 'edit')) {
$this->flashMessage('authorization.noPermission', FlashMessage::WARNING);
return;
}
$values = $form->getValues(true);
$values['saveAsDraft'] = (bool) $isDraft;
$values['author'] = $this->user;
$tags = $form->getHttpData(Form::DATA_TEXT, 'tags[]');
$values['tags'] = $tags;
try {
$page = $this->pageFacade->save($values, $this->page);
$this->flashMessage('pageEditForm.messages.success' . ($values['saveAsDraft'] ? 'Draft' : 'Publish'), FlashMessage::SUCCESS);
$this->onSuccessPageSaving($this, $page);
} catch (PagePublicationTimeMissingException $ptm) {
$form->addError($this->translator->translate('pageEditForm.messages.missingPublicationTime'));
return;
} catch (PagePublicationTimeException $pt) {
$form->addError($this->translator->translate('pageEditForm.messages.publishedPageInvalidPublicationTime'));
return;
} catch (PageIntroHtmlLengthException $pi) {
$form->addError($this->translator->translate('pageEditForm.messages.pageIntroHtmlLength'));
return;
} catch (PageTitleAlreadyExistsException $at) {
$form->addError($this->translator->translate('pageEditForm.messages.titleExists'));
return;
} catch (UrlAlreadyExistsException $ur) {
$form['url']->setValue(Strings::webalize($values['title'], '/'));
$form->addError($this->translator->translate('pageEditForm.messages.urlExists'));
return;
} catch (DBALException $e) {
$form->addError($this->translator->translate('pageEditForm.messages.savingError'));
return;
}
}
示例4: saveEvent
public function saveEvent(Form $form)
{
$values = $form->getValues();
if ($form['save']->isSubmittedBy()) {
$categories = $values['categories'];
unset($values['categories']);
if ($form->onSuccess) {
unset($values['agree']);
$values['user_id'] = $this->user->loggedIn ? $this->user->id : null;
$values['subject_id'] = 1;
// anonymní akce // anonymní subjekt
$values['approved'] = 0;
$values['visible'] = 1;
$values['reviewed'] = 0;
$pd = $this->context->createService('events')->insert($values);
$id = $pd->id;
$this->flashMessage('Akce uložena do zásobníku', 'success');
\dibi::begin();
foreach ($categories as $n) {
\dibi::query('INSERT INTO [event_x_category] SET [event_id]=%i', $id, ', [category_id]=%i', $n);
}
\dibi::commit();
}
$form->addError('Something bad happend.');
}
$this->redirect('upload-photos', array('event_id' => $id));
}
示例5: addErrorsToForm
/**
* Add errors to form (form helper)
* @param Form form
*/
public function addErrorsToForm(Form $form)
{
foreach ($this->getRuleViolations() as $issue) {
$name = $issue->getName();
if ($name !== null && isset($form[$name])) {
$form[$name]->addError($issue->getMessage());
} else {
$form->addError($issue->getMessage());
}
}
}