当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::addError方法代码示例

本文整理汇总了PHP中yii\base\Model::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::addError方法的具体用法?PHP Model::addError怎么用?PHP Model::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\base\Model的用法示例。


在下文中一共展示了Model::addError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateAttribute

 /**
  * server validatiom for unique zip_code
  * @param \yii\base\Model $model
  * @param string $attribute
  */
 public function validateAttribute($model, $attribute)
 {
     $value = $model->{$attribute};
     if (!Locations::find()->where(['zip_code' => $value])->exists()) {
         $model->addError($attribute, $this->message);
     }
 }
开发者ID:sydorenkovd,项目名称:yiiadv,代码行数:12,代码来源:ZipcodeValidator.php

示例2: checkRequiredParams

 public static function checkRequiredParams($params, $required_params)
 {
     $missing_parameters = self::allTheRequiredParametersAre($params, $required_params);
     $model = new Model();
     if ($missing_parameters) {
         $model->addError("this parameters are missing ", $error = implode(", ", $missing_parameters));
     }
     return $model;
 }
开发者ID:avrahamichler,项目名称:Highnet,代码行数:9,代码来源:ApiParams.php

示例3: addError

 /**
  * Adds an error about the specified attribute to the model object.
  * This is a helper method that performs message selection and internationalization.
  * @param \yii\base\Model $model the data model being validated
  * @param string $attribute the attribute being validated
  * @param string $message the error message
  * @param array $params values for the placeholders in the error message
  */
 public function addError($model, $attribute, $message, $params = [])
 {
     $params['attribute'] = $model->getAttributeLabel($attribute);
     if (!isset($params['value'])) {
         $value = $model->{$attribute};
         if (is_array($value)) {
             $params['value'] = 'array()';
         } elseif (is_object($value) && !method_exists($value, '__toString')) {
             $params['value'] = '(object)';
         } else {
             $params['value'] = $value;
         }
     }
     $model->addError($attribute, Yii::$app->getI18n()->format($message, $params, Yii::$app->language));
 }
开发者ID:nanodesu88,项目名称:yii2,代码行数:23,代码来源:Validator.php

示例4: addError

 /**
  * Adds an error about the specified attribute to the model object.
  * This is a helper method that performs message selection and internationalization.
  * @param \yii\base\Model $object the data object being validated
  * @param string $attribute the attribute being validated
  * @param string $message the error message
  * @param array $params values for the placeholders in the error message
  */
 public function addError($object, $attribute, $message, $params = [])
 {
     $value = $object->{$attribute};
     $params['attribute'] = $object->getAttributeLabel($attribute);
     $params['value'] = is_array($value) ? 'array()' : $value;
     $object->addError($attribute, Yii::$app->getI18n()->format($message, $params, Yii::$app->language));
 }
开发者ID:pathman,项目名称:yii2comm,代码行数:15,代码来源:Validator.php

示例5: addError

 /**
  * Adds an error about the specified attribute to the model object.
  * This is a helper method that performs message selection and internationalization.
  * @param \yii\base\Model $model the data model being validated
  * @param string $attribute the attribute being validated
  * @param string $message the error message
  * @param array $params values for the placeholders in the error message
  */
 public function addError($model, $attribute, $message, $params = [])
 {
     $params['attribute'] = $model->getAttributeLabel($attribute);
     if (!isset($params['value'])) {
         $value = $model->{$attribute};
         $params['value'] = is_array($value) ? 'array()' : $value;
     }
     $model->addError($attribute, Yii::$app->getI18n()->format($message, $params, Yii::$app->language));
 }
开发者ID:sadiqhirani,项目名称:yii2,代码行数:17,代码来源:Validator.php


注:本文中的yii\base\Model::addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。