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


PHP Form::getErrors方法代码示例

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


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

示例1: findErrors

 /**
  * @return array
  */
 public function findErrors()
 {
     $formErrors = method_exists($this->form, 'getAllErrors') ? $this->form->getErrors() : $this->form->getErrors();
     if (!$formErrors) {
         return array();
     }
     $form = $this->form;
     $translate = function ($errors) use($form) {
         if ($translator = $form->getTranslator()) {
             // If we have translator, translate!
             foreach ($errors as $key => $val) {
                 $errors[$key] = $translator->translate($val);
             }
         }
         return $errors;
     };
     if (!$this->errorsAtInputs) {
         return $translate($formErrors);
     }
     if (method_exists($this->form, 'getAllErrors')) {
         return $translate($this->form->getErrors());
     }
     foreach ($this->form->getControls() as $control) {
         /** @var \Nette\Forms\Controls\BaseControl $control */
         if (!$control->hasErrors()) {
             continue;
         }
         $formErrors = array_diff($formErrors, $control->getErrors());
     }
     return $translate($formErrors);
 }
开发者ID:TomHetmer,项目名称:logs-db,代码行数:34,代码来源:BootstrapRenderer.php

示例2: renderGlobalErrors

 /**
  * @param bool $ownOnly - true = render only global errors, false = render all errors of all controls
  * @return Html
  */
 public function renderGlobalErrors($ownOnly = TRUE)
 {
     $errors = $ownOnly ? $this->form->getOwnErrors() : $this->form->getErrors();
     $container = clone $this->prototypes->getGlobalErrors();
     foreach ($errors as $error) {
         $alert = clone $this->prototypes->getGlobalError();
         $this->addContent($alert->getPlaceholder(), $error);
         $container->getPlaceholder()->addHtml($alert);
     }
     return $container;
 }
开发者ID:instante,项目名称:bootstrap3renderer,代码行数:15,代码来源:BootstrapRenderer.php

示例3: renderErrors

 /**
  * Renders validation errors (per form or per control).
  * @return string
  */
 public function renderErrors(Nette\Forms\IControl $control = NULL)
 {
     $errors = $control === NULL ? $this->form->getErrors() : $control->getErrors();
     if (count($errors)) {
         $ul = $this->getWrapper('error container');
         $li = $this->getWrapper('error item');
         foreach ($errors as $error) {
             $item = clone $li;
             if ($error instanceof Html) {
                 $item->add($error);
             } else {
                 $item->setText($error);
             }
             $ul->add($item);
         }
         return "\n" . $ul->render(0);
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:22,代码来源:DefaultFormRenderer.php

示例4: findErrors

 /**
  * @return array
  */
 public function findErrors()
 {
     $formErrors = $this->errorsAtInputs ? $this->form->getOwnErrors() : $this->form->getErrors();
     if (!$formErrors) {
         return array();
     }
     $form = $this->form;
     $translate = function ($errors) use($form) {
         if ($translator = $form->getTranslator()) {
             // If we have translator, translate!
             foreach ($errors as $key => $val) {
                 $errors[$key] = $translator->translate($val);
             }
         }
         return $errors;
     };
     return $translate($formErrors);
 }
开发者ID:honzaskovran,项目名称:bootstrap3renderer,代码行数:21,代码来源:BootstrapRenderer.php

示例5: renderErrors

 /**
  * Renders validation errors (per form or per control).
  * @return string
  */
 public function renderErrors(Nette\Forms\IControl $control = NULL, $own = TRUE)
 {
     $errors = $control ? $control->getErrors() : ($own ? $this->form->getOwnErrors() : $this->form->getErrors());
     if (!$errors) {
         return;
     }
     $container = $this->getWrapper($control ? 'control errorcontainer' : 'error container');
     $item = $this->getWrapper($control ? 'control erroritem' : 'error item');
     foreach ($errors as $error) {
         $item = clone $item;
         if ($error instanceof Html) {
             $item->add($error);
         } else {
             $item->setText($error);
         }
         $container->add($item);
     }
     return "\n" . $container->render($control ? 1 : 0);
 }
开发者ID:luminousinfoways,项目名称:pccfoas,代码行数:23,代码来源:DefaultFormRenderer.php

示例6: findErrors

 /**
  * @return array
  */
 public function findErrors()
 {
     if (!($formErrors = $this->form->getErrors())) {
         return array();
     }
     if (!$this->errorsAtInputs) {
         return $formErrors;
     }
     foreach ($this->form->getControls() as $control) {
         /** @var \Nette\Forms\Controls\BaseControl $control */
         if (!$control->hasErrors()) {
             continue;
         }
         $formErrors = array_diff($formErrors, $control->getErrors());
     }
     // If we have translator, translate!
     if ($translator = $this->form->getTranslator()) {
         foreach ($formErrors as $key => $val) {
             $formErrors[$key] = $translator->translate($val);
         }
     }
     return $formErrors;
 }
开发者ID:rostenkowski,项目名称:nette-forms-renderer,代码行数:26,代码来源:BootstrapRenderer.php

示例7: render

 /**
  * Render the templates
  *
  * @param \Nette\Forms\Form $form
  * @return void
  */
 public function render(\Nette\Forms\Form $form)
 {
     if ($form === $this->form) {
         // don't forget for second run, @hosiplan! ;)
         foreach ($this->form->getControls() as $control) {
             $control->setOption('rendered', FALSE);
         }
         echo $this->template;
         return;
     }
     // Store the current form instance
     $this->form = $form;
     // Translator available?
     if ($translator = $form->getTranslator()) {
         // intentional =
         $this->template->setTranslator($translator);
     }
     // Pre-proccess form
     $errors = $form->getErrors();
     foreach ($form->getControls() as $control) {
         $control->setOption('rendered', FALSE);
         if (!$control->getOption('blockname', FALSE)) {
             $ex = explode('\\', get_class($control));
             $control->setOption('blockname', end($ex));
         }
         if ($this->errorsAtInputs) {
             $errors = array_diff($errors, $control->errors);
         }
     }
     // Assign to template
     $this->template->form = $form;
     $this->template->errors = $errors;
     $this->template->renderer = $this;
     $this->template->errorsAtInputs = $this->errorsAtInputs;
     // And echo the output
     echo $this->template;
 }
开发者ID:valicek1,项目名称:nestraps,代码行数:43,代码来源:Nestraps.php

示例8: foreach

      });
    });
    //]]> -->
  </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 
}
?>
  <div class="form-group">
    <?php 
echo $form['date']->getLabel();
开发者ID:radekdostal,项目名称:nette-datetimepicker,代码行数:31,代码来源:TbDateTimePicker.php

示例9:

		text-align: right;
	}
	</style>

	<script src="netteForms.js"></script>
</head>

<body>
	<h1>Nette\Forms manual form rendering</h1>

	<?php 
$form->render('begin');
?>

	<?php 
if ($form->getErrors()) {
    ?>
	<p>Opravte chyby:</p>
	<?php 
    $form->render('errors');
    ?>
	<?php 
}
?>

	<fieldset>
		<legend>Personal data</legend>
		<table>
		<tr class="required">
			<th><?php 
echo $form['name']->getLabel('Your name:');
开发者ID:jakubkulhan,项目名称:nette,代码行数:31,代码来源:manual-rendering.php

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