当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::addError方法代码示例

本文整理汇总了PHP中Venne\Forms\Form::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addError方法的具体用法?PHP Form::addError怎么用?PHP Form::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Venne\Forms\Form的用法示例。


在下文中一共展示了Form::addError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleCatchError

 public function handleCatchError(Form $form, $e)
 {
     if ($e instanceof InvalidArgumentException) {
         $form->addError($e->getMessage());
         return TRUE;
     } else {
         if ($e instanceof DBALException && strpos($e->getMessage(), 'Duplicate entry') !== false) {
             $form->addError('Duplicate entry');
             return TRUE;
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:12,代码来源:FormFactory.php

示例2: handleSave

 public function handleSave(Form $form)
 {
     $values = $form->values;
     if ($values['file']->isOk()) {
         if ($values['cleanout']) {
             foreach ($this->userRepository->findAll() as $user) {
                 $this->userRepository->delete($user);
             }
         }
         /** @var FileUpload $file */
         $file = $values['file'];
         $data = file_get_contents($file->getTemporaryFile());
         foreach (explode("\n", $data) as $row) {
             if (!$row) {
                 continue;
             }
             $items = explode(',', $row);
             if (!count($items)) {
                 continue;
             }
             try {
                 $user = new UserEntity(trim($items[0]));
             } catch (InvalidArgumentException $e) {
                 $form->addError($e->getMessage());
             }
             $this->userRepository->save($user);
         }
     }
 }
开发者ID:venne,项目名称:newsletter-module,代码行数:29,代码来源:ImportFormFactory.php

示例3: handleCatchError

 public function handleCatchError(Form $form, $e)
 {
     if ($e instanceof DBALException && $e->getCode() == '23000') {
         $form->addError('User is not unique');
         return TRUE;
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:BaseAdminFormFactory.php

示例4: handleCatchError

 public function handleCatchError(Form $form, $e)
 {
     if ($e instanceof PermissionDeniedException) {
         $form->addError('You have not writable permissions.');
         return TRUE;
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:FileFormFactory.php

示例5: handleValidate

 public function handleValidate(Form $form)
 {
     if (!isset($this->sessionSection->captcha) || $form['_captcha']->value != $this->sessionSection->captcha) {
         $form->addError('Nesprávně opsaný obrázek, zkuste to prosím znovu');
         $form['_captcha']->setOption('description', Html::el('img')->src($this->getCaptchaBuilder()->inline()));
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:FormFactory.php

示例6: handleSuccess

 public function handleSuccess(Form $form)
 {
     $values = $form->getValues();
     $oldPath = $this->moduleHelpers->expandPath($form->data, 'Resources/layouts');
     $form->data = $this->getKeyByValues($values);
     $path = $this->moduleHelpers->expandPath($form->data, 'Resources/layouts');
     umask(00);
     if (!file_exists(dirname($path))) {
         if (!@mkdir(dirname($path), 0777, TRUE)) {
             $form->addError("File '{$path}' is not writable.");
         }
     }
     file_put_contents($path, $values['text']);
     if ($oldPath && $oldPath !== $path) {
         @unlink($oldPath);
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:17,代码来源:LayouteditFormFactory.php

示例7: handleCatchError

 public function handleCatchError(Form $form, $e)
 {
     $m = explode("'", $e->getMessage());
     $form->addError("Duplicate entry '{$m[1]}'");
     return true;
 }
开发者ID:svobodni,项目名称:web,代码行数:6,代码来源:LanguageFormFactory.php

示例8: handleSuccess

 public function handleSuccess(Form $form)
 {
     if ($form->isSubmitted() === $form->getSaveButton()) {
         $values = $form->values;
         if ($values['type'] == 'component') {
             $file = $this->getFileByClass($values['component']);
             $baseName = $file->getBasename('.php') . '.latte';
             $template = $file->getPath() . '/' . $baseName;
             $target = $this->moduleHelpers->expandPath('@' . $values['target'] . 'Module', 'Resources/layouts');
             if ($values['layout']) {
                 $target .= '/' . $values['layout'];
             }
             $target .= '/' . $baseName;
         } else {
             $presenter = explode(':', $values['presenter']);
             $module = lcfirst($presenter[0]);
             $page = lcfirst($presenter[2]);
             $presenter = lcfirst($presenter[3]);
             $template = $this->moduleHelpers->expandPath('@' . $module . 'Module/@' . $page . '.' . $presenter . '.latte', 'Resources/layouts');
             $target = $this->moduleHelpers->expandPath('@' . $values['target'] . 'Module/' . ($values['layout'] ? $values['layout'] . '/' : '') . '@' . $page . '.' . $presenter . '.latte', 'Resources/layouts');
         }
         if (!copy($template, $target)) {
             $form->addError("Unable to copy file '{$template}' to '{$target}'.");
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:26,代码来源:OverloadFormFactory.php

示例9: handleCatchError

 public function handleCatchError(Form $form, $e)
 {
     $form->addError($e->getMessage());
     return true;
 }
开发者ID:svobodni,项目名称:web,代码行数:5,代码来源:SpecialFormFactory.php


注:本文中的Venne\Forms\Form::addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。