当前位置: 首页>>代码示例>>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;未经允许,请勿转载。