當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CModel::getErrors方法代碼示例

本文整理匯總了PHP中CModel::getErrors方法的典型用法代碼示例。如果您正苦於以下問題:PHP CModel::getErrors方法的具體用法?PHP CModel::getErrors怎麽用?PHP CModel::getErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CModel的用法示例。


在下文中一共展示了CModel::getErrors方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: errorModelSummery

 /**
  * get error info from model
  * 
  * @param CModel $model
  * @return string
  * @see CModel
  */
 public static function errorModelSummery($model, $attribute = null)
 {
     if (is_null($attribute)) {
         return self::errorSummery($model->getErrors());
     } else {
         $aryError = $model->getError($attribute, false);
         return empty($aryError) ? '' : self::errorSummery(array($aryError));
     }
 }
開發者ID:erdincay,項目名稱:WIIBOX,代碼行數:16,代碼來源:CHtml.php

示例2: generateModelErrorFields

 /**
  * @param \CModel $model
  * @param null $path
  * @return array
  */
 public function generateModelErrorFields(\CModel $model, $path = null)
 {
     $validators = \CValidator::$builtInValidators;
     if ($this->hasEventHandler('onBeforeGenerateError')) {
         $this->onBeforeGenerateError(new \CEvent($this, array('model' => $model)));
     }
     $errors = $model->getErrors();
     $errorFields = array_keys($errors);
     $errorHandled = array();
     $i = 0;
     $result = array();
     foreach ($model->getValidators() as $validator) {
         if (isset($hasError) && $validator->skipOnError || !array_intersect($validator->attributes, $errorFields)) {
             continue;
         }
         $model->clearErrors();
         $validator->validate($model);
         if ($model->hasErrors()) {
             $hasError = true;
             $code = array_search(get_class($validator), $validators);
             if ($validator instanceof \CInlineValidator) {
                 $code = $validator->method;
             }
             foreach ($validator->attributes as $attribute) {
                 if ($model->hasErrors($attribute)) {
                     $result[$i]['code'] = $code;
                     $result[$i]['message'] = $model->getError($attribute);
                     $result[$i]['name'] = $path ? $path . '[' . $attribute . ']' : $attribute;
                     $errorHandled[] = $attribute;
                     $i++;
                 }
             }
         }
     }
     foreach (array_diff($errorFields, $errorHandled) as $attribute) {
         $result[$i]['code'] = 'unknown';
         $result[$i]['message'] = implode(',', $errors[$attribute]);
         $result[$i]['name'] = $path ? $path . '[' . $attribute . ']' : $attribute;
     }
     return $result;
 }
開發者ID:elrodox,項目名稱:JardinConejitoBlanco,代碼行數:46,代碼來源:Service.php

示例3: _generateModelErrorFields

 /**
  * @param \CModel $model
  * @return array
  */
 protected function _generateModelErrorFields(\CModel $model)
 {
     $validators = \CValidator::$builtInValidators;
     $errors = $model->getErrors();
     $errorFields = array_keys($errors);
     $errorHandled = array();
     $i = 0;
     $result = array();
     foreach ($model->getValidators() as $validator) {
         if (isset($hasError) && $validator->skipOnError || !array_intersect($validator->attributes, $errorFields)) {
             continue;
         }
         $model->clearErrors();
         $validator->validate($model);
         if ($model->hasErrors()) {
             $hasError = true;
             $code = array_search(get_class($validator), $validators);
             if ($validator instanceof \CInlineValidator) {
                 $code = $validator->method;
             }
             foreach ($validator->attributes as $attribute) {
                 if ($model->hasErrors($attribute)) {
                     $result[$i]['code'] = $code;
                     $result[$i]['message'] = $model->getError($attribute);
                     $result[$i]['name'] = $attribute;
                     $errorHandled[] = $attribute;
                     $i++;
                 }
             }
         }
     }
     foreach (array_diff($errorFields, $errorHandled) as $attribute) {
         $result[$i]['code'] = 'unknown';
         $result[$i]['message'] = implode(',', $errors[$attribute]);
         $result[$i]['name'] = $attribute;
     }
     return $result;
 }
開發者ID:rosko,項目名稱:yii-rest-api,代碼行數:42,代碼來源:Service.php

示例4: getErrors

 /**
  * Return array of errors on form and model.
  * Currently this method does not support specifying the $attributeNameOrNames parameter.
  */
 public function getErrors($attributeNameOrNames = null)
 {
     $formErrors = parent::getErrors($attributeNameOrNames);
     $modelErrors = $this->model->getErrors($attributeNameOrNames);
     return array_merge($formErrors, $modelErrors);
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:10,代碼來源:ModelForm.php


注:本文中的CModel::getErrors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。