當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。