本文整理匯總了PHP中JModel::getErrors方法的典型用法代碼示例。如果您正苦於以下問題:PHP JModel::getErrors方法的具體用法?PHP JModel::getErrors怎麽用?PHP JModel::getErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JModel
的用法示例。
在下文中一共展示了JModel::getErrors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handleError
/**
* Handle the view error
*
* @param JView $view View
* @param JModel $model Form Model
*
* @since 3.1b
*
* @return void
*/
protected function handleError($view, $model)
{
$app = JFactory::getApplication();
$package = $app->getUserState('com_fabrik.package', 'fabrik');
$input = $app->input;
$validated = false;
// If its in a module with ajax or in a package or inline edit
if ($input->get('fabrik_ajax')) {
if ($input->getInt('elid', 0) !== 0) {
// Inline edit
$eMsgs = array();
$errs = $model->getErrors();
// Only raise errors for fields that are present in the inline edit plugin
$toValidate = array_keys($input->get('toValidate', array(), 'array'));
foreach ($errs as $errorKey => $e) {
if (in_array($errorKey, $toValidate) && count($e[0]) > 0) {
array_walk_recursive($e, array('FabrikString', 'forHtml'));
$eMsgs[] = count($e[0]) === 1 ? '<li>' . $e[0][0] . '</li>' : '<ul><li>' . implode('</li><li>', $e[0]) . '</ul>';
}
}
if (!empty($eMsgs)) {
$eMsgs = '<ul>' . implode('</li><li>', $eMsgs) . '</ul>';
header('HTTP/1.1 500 ' . FText::_('COM_FABRIK_FAILED_VALIDATION') . $eMsgs);
jexit();
} else {
$validated = true;
}
} else {
// Package / model
echo $model->getJsonErrors();
}
if (!$validated) {
return;
}
}
if (!$validated) {
$this->savepage();
if ($this->isMambot) {
$this->setRedirect($this->getRedirectURL($model, false));
} else {
/**
* $$$ rob - http://fabrikar.com/forums/showthread.php?t=17962
* couldn't determine the exact set up that triggered this, but we need to reset the rowid to -1
* if reshowing the form, otherwise it may not be editable, but rather show as a detailed view
*/
if ($input->get('usekey', '') !== '') {
$input->set('rowid', -1);
}
// Meant that the form's data was in different format - so redirect to ensure that its showing the same data.
$input->set('task', '');
$view->display();
}
return;
}
}