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


PHP Form::hasErrors方法代码示例

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


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

示例1: uploadPhotosFormSucceded

 /**
  * Processing of Upload Photos Form
  *
  * @Privilege('generate')
  *
  * @param Form $form
  */
 public function uploadPhotosFormSucceded(Form $form)
 {
     $values = $form->getValues();
     $event = $this->loadItem($values['id']);
     $calendar = $event->ref('calendar');
     $year = $calendar->yearpart === 'podzim' ? $calendar->year : $calendar->year - 1;
     $date = substr($event->datestart, 0, 4) . substr($event->datestart, 5, 2) . substr($event->datestart, 8, 2);
     // check if the year dir exist. if not, create one
     $params = $this->context->parameters;
     $dirYear = $params['wwwDir'] . $params['chroniclePhotosStorage'] . '/' . $year . ($year + 1) . '/';
     // check if the event dir exists. if not, create one
     $dir = $dirYear . $date . '/';
     if (!file_exists($dir)) {
         mkdir($dir, 0777, TRUE);
     }
     \Tracy\Debugger::barDump($dir);
     // start uploading files
     $counter = 0;
     foreach ($values['upload'] as $file) {
         if ($file->isOK()) {
             if ($file->isImage()) {
                 do {
                     $counter += 1;
                     //increment counter until you hit empty space for file
                     $filePath = $dir . \Nette\Utils\Strings::padLeft($counter, 4, '0') . '.jpg';
                 } while (file_exists($filePath));
                 $image = $file->toImage();
                 $image->save($filePath, 85, \Nette\Image::JPEG);
                 $this->database->table('chronicle_photos')->insert(['event_id' => $values['id'], 'order' => $counter]);
                 $this->flashMessage("Soubor " . $file->getName() . " byl úspěšně nahrán!");
             } else {
                 $form->addError('Soubor' . $file->getName() . ' nebyl rozpoznán jako fotka.');
             }
         } else {
             $form->addError('Nepodařilo se nahrát soubor:' . $file->getName());
         }
     }
     //change event visibility
     if (!array_key_exists('showchronicle', $values)) {
         //user did not have the sufficient permission
         $showchronicle = FALSE;
     } else {
         $showchronicle = $values['showchronicle'] ? TRUE : FALSE;
     }
     $this->events->showChronicle($values['id'], $showchronicle);
     if (!$form->hasErrors()) {
         $this->redirect('default');
     }
 }
开发者ID:patrickkusebauch,项目名称:27skauti,代码行数:56,代码来源:ChroniclePresenter.php

示例2: validate

 public function validate(Form $form, $values)
 {
     if ($values->login_name != "AB") {
         $form["login_name"]->addError("Nenapsal jsi AB");
     }
     if ($form->hasErrors()) {
         $this->presenter->flashMessage("Form has some errors!!", "danger");
     }
 }
开发者ID:chapcz,项目名称:sandbox,代码行数:9,代码来源:FormTester.php

示例3: quickPickFormError

 public function quickPickFormError(Form $form)
 {
     if ($form->hasErrors() && $this->presenter->isAjax()) {
         $errors = $form->getErrors();
         $error = array_shift($errors);
         $this->presenter->payload->error = true;
         $this->presenter->payload->message = $error;
         $this->presenter->sendPayload();
     }
 }
开发者ID:rostenkowski,项目名称:vstore,代码行数:10,代码来源:QuickPick.php

示例4: validateAddReservationForm

 public function validateAddReservationForm(Form $form, $values)
 {
     $date = DateTimeUtils::createDbDatetimeFormatFromDateParts($values->year, $values->month, $values->day, "0", "0", "0");
     $validDate = DateTimeUtils::createDateTime(DateTimeUtils::DB_DATETIME_FORMAT, $date);
     if (!$validDate) {
         $form->addError("Zadej prosím platné datum.");
     } elseif ($validDate->format(DateTimeUtils::DB_DATE_FORMAT) < DateTimeUtils::getNow()->format(DateTimeUtils::DB_DATE_FORMAT)) {
         $form->addError("Nemůžeš si zpětně rezervovat zápas.");
     }
     if ($form->getPresenter()->isAjax() && $form->hasErrors()) {
         if ($values->reservationId == 0) {
             $form->getPresenter()->redrawControl("addReservation");
         } else {
             $form->getPresenter()->redrawControl("editReservation");
         }
     }
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:17,代码来源:AddReservationForm.php

示例5: addHlasinekFormSucceded

 /**
  * Processing of Add Hlasinek Form
  *
  * @Privilege("addall")
  *
  * @param Form $form
  */
 public function addHlasinekFormSucceded(Form $form)
 {
     $values = $form->getValues(TRUE);
     $folder = $values['folder'];
     unset($values['folder']);
     $month_number = $values['month_number'];
     unset($values['month_number']);
     unset($values['send']);
     $params = $this->context->parameters;
     $path = $params['wwwDir'] . $params['hlasinekStorage'] . '/' . $folder . '/';
     foreach ($values as $key => $file) {
         if ($file->isOk()) {
             if ($file->isImage()) {
                 //make sure the file will be GIF
                 $image = $file->toImage();
                 $filename = 'hlas' . $month_number . mb_substr($key, 0, 2) . '.gif';
                 $image->save($path . $filename, NULL, \Nette\Image::GIF);
                 $this->flashMessage('Náhled byl úspěšně nahrán.');
             } else {
                 //file is PDF
                 $filename = 'hlas' . $month_number . mb_substr($key, 0, 2) . '.' . mb_substr($key, 2, 5);
                 $file->move($path . $filename);
                 $this->flashMessage('Dokument byl úspěšně nahrán.');
             }
         } else {
             if ($file->getError() != 4) {
                 //no file was selected - not an error
                 $form->addError('Soubor se nepodařilo nahrát. Důvod: ' . $file->getError());
             }
         }
     }
     if (!$form->hasErrors()) {
         $this->redirect('default');
     }
 }
开发者ID:patrickkusebauch,项目名称:27skauti,代码行数:42,代码来源:HlasinekPresenter.php


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