本文整理匯總了PHP中Nette\Forms\Form::getOwnErrors方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::getOwnErrors方法的具體用法?PHP Form::getOwnErrors怎麽用?PHP Form::getOwnErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::getOwnErrors方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}