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


PHP Form::hasErrors方法代码示例

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


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

示例1: foreach

        language: 'cs',  // en
        format: 'dd.mm.yyyy hh:ii',  // mm/dd/yyyy hh:ii
        autoclose: true,
        todayBtn: true
      });
    });
    //]]> -->
  </script>
</head>
<body>
  <h1>RadekDostal\NetteComponents\DateTimePicker\TbDateTimePicker example</h1>
  <?php 
$form->render('begin');
?>
  <?php 
if ($form->hasErrors() === TRUE) {
    ?>
  <ul class="error">
    <?php 
    foreach ($form->getErrors() as $error) {
        ?>
    <li><?php 
        echo htmlspecialchars($error);
        ?>
</li>
    <?php 
    }
    ?>
  </ul>
  <?php 
}
开发者ID:radekdostal,项目名称:nette-datetimepicker,代码行数:31,代码来源:TbDateTimePicker.php

示例2: processActions

 /**
  * Do the magic
  */
 public function processActions()
 {
     // WP_List_Table export
     \SimpleSubscribe\TableSubscribes::process();
     // settings form
     if ($this->formSettings->isSubmitted() && $this->formSettings->isValid()) {
         $values = $this->formSettings->getValues(TRUE);
         // if there are cateogires selected, and ALL as well, uncheck remaining
         if (count(array_filter($values['cat'])) > 0 && $values['cat']['0'] == TRUE) {
             foreach ($values['cat'] as $key => $value) {
                 $values['cat'][$key] = FALSE;
                 $this->formSettings['cat'][$key]->value = FALSE;
             }
             $values['cat']['0'] = TRUE;
             $this->formSettings['cat']['0']->value = TRUE;
             // if there is other category selected, unselect ALL
         } elseif (count(array_filter($values['cat'])) > 1) {
             $values['cat']['0'] = FALSE;
             $this->formSettings['cat']['0']->value = FALSE;
             // if there's no category selected, select ALL
         } elseif (!in_array(TRUE, $values['cat'])) {
             $values['cat']['0'] = TRUE;
             $this->formSettings['cat']['0']->value = TRUE;
         }
         $this->settings->saveSettings($values);
         $this->addNotice('updated', 'Settings successfully saved.');
     } elseif ($this->formSettings->hasErrors()) {
         foreach ($this->formSettings->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // email template (saved in settings table tho)
     if ($this->formEmailTemplate->isSubmitted() && $this->formEmailTemplate->isValid()) {
         $this->settings->saveSettings($this->formEmailTemplate->getValues(TRUE));
         $this->addNotice('updated', 'Settings successfully saved.');
     } elseif ($this->formEmailTemplate->hasErrors()) {
         foreach ($this->formEmailTemplate->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // mass email
     if ($this->formEmail->isSubmitted() && $this->formEmail->isValid()) {
         try {
             $this->email->sendMassEmail($this->formEmail->getValues(TRUE));
             $this->addNotice('updated', 'Email successfully sent.');
         } catch (EmailException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formEmail->hasErrors()) {
         foreach ($this->formEmail->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // subscriber form
     if ($this->formSubscriber->isSubmitted() && $this->formSubscriber->isValid()) {
         try {
             $this->subscribers->addThruAdmin($this->formSubscriber->getValues());
             $this->addNotice('updated', 'Subscriber successfully added.');
         } catch (RepositarySubscribersException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formSubscriber->hasErrors()) {
         foreach ($this->formSubscriber->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // wp subscriber form
     if ($this->formSubscriberWp->isSubmitted() && $this->formSubscriberWp->isValid()) {
         try {
             $users = $this->formSubscriberWp->getValues(TRUE);
             $this->subscribers->addWpRegistered($users['users']);
             $this->addNotice('updated', 'Subscriber(s) successfully added.');
         } catch (RepositarySubscribersException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formSubscriberWp->hasErrors()) {
         foreach ($this->formSubscriberWp->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
     // email preview form
     if ($this->formEmailPreview->isSubmitted() && $this->formEmailPreview->isValid()) {
         try {
             $this->email->sendEmailPreview($this->formEmailPreview->getValues(TRUE));
             $this->addNotice('updated', 'Email Preview successfully sent.');
         } catch (EmailException $e) {
             $this->addNotice('error', $e->getMessage());
         }
     } elseif ($this->formEmailPreview->hasErrors()) {
         foreach ($this->formEmailPreview->getErrors() as $error) {
             $this->addNotice('error', $error);
         }
     }
 }
开发者ID:hkarriche,项目名称:wordpress,代码行数:97,代码来源:Admin.php


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