當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::addError方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:zaxxx,項目名稱:zaxcms,代碼行數:35,代碼來源:LoginFormControl.php

示例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!');
     }
 }
開發者ID:B4rtosek,項目名稱:sislak,代碼行數:11,代碼來源:LoginPresenter.php

示例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;
     }
 }
開發者ID:blitzik,項目名稱:CMS,代碼行數:36,代碼來源:PageFormControl.php

示例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));
 }
開發者ID:soundake,項目名稱:pd,代碼行數:27,代碼來源:AddPresenter.php

示例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());
         }
     }
 }
開發者ID:janmarek,項目名稱:Ormion,代碼行數:15,代碼來源:Record.php


注:本文中的Nette\Forms\Form::addError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。