本文整理汇总了PHP中Nette\Application\UI\Form::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getErrors方法的具体用法?PHP Form::getErrors怎么用?PHP Form::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::getErrors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FormError
/**
* Odeslání formuláře s Errory
* @param Form $form
*/
public function FormError(Form $form)
{
$json = new \stdClass();
$json->result = "error";
$json->message = implode("<br />", $form->getErrors());
$json->notify = implode(",", $form->getErrors());
$response = new JsonResponse($json);
$this->getPresenter()->sendResponse($response);
}
示例2: 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();
}
}
示例3: renderAllErrors
public function renderAllErrors(UI\Form $form)
{
$html = '';
foreach ($form->getErrors() as $error) {
$html .= '<div class="alert alert-danger">
<a class="close" data-dismiss="alert">×</a>' . $error . '
</div>';
}
$errors = new Html();
$errors->setHtml($html);
return $errors;
}
示例4: formError
/**
* Process form if error occurs.
* @param void
*/
public function formError(Form $form)
{
$errors = $form->getErrors();
foreach ($errors as $error) {
$this->presenter->flashMessage($error, "error");
}
switch ($form->name) {
case "formEdit":
$this->handleEdit();
break;
case "formUpload":
$this->handleUpload();
break;
}
}
示例5: validateAddArticleForm
public function validateAddArticleForm(Form $form)
{
$values = (object) $form->getHttpData();
if ($values->publishedAt == "later") {
$later = DateTimeUtils::createDbDatetimeFormatFromDateParts($values->year, $values->month, $values->day, $values->hour, $values->minute, "0");
$valid = DateTimeUtils::createDateTime(DateTimeUtils::DB_DATETIME_FORMAT, $later);
if (!$valid) {
$form->addError("Zadej prosím platné datum");
}
}
if ($values->photoId == 0) {
$form->addError("Vyber prosím fotografii ke článku.");
}
if (!isset($values->tagList)) {
$tagList = null;
$form->addError("Zadej prosím alespoň jeden tag ke článku.");
} else {
$tagList = new TagCollection();
foreach ($values->tagList as $tag) {
$tagList->addItem(TagService::create($tag));
}
}
$articleId = $form->getPresenter()->getParameter("articleId");
if (count($form->getErrors()) > 0) {
if ($articleId) {
$form->getPresenter()->actionEdit(null, $tagList, $values->photoId);
} else {
$form->getPresenter()->actionAdd($tagList, $values->photoId);
}
}
}
示例6: onFormError
/**
* @author Petr Besir Horacek <sirbesir@gmail.com>
* @param \Nette\Application\UI\Form $form
* @return boolean
*/
public function onFormError(\Nette\Application\UI\Form $form)
{
$errors = $form->getErrors();
foreach ($errors as $error) {
if ($this->getToGlobalFlashes()) {
$this->getPresenter()->flashMessage($error, 'error');
} else {
$this->flashMessage('Při odesílání zprávy došlo k neznámé chybě. Zkuste to prosím později.', 'error');
}
}
return FALSE;
}