12345678910111213141516171819202122232425 |
- <?php
- //model 的重写基类
- namespace app\common\models;
- use Yii;
- use yii\base\Model;
- class EModel extends Model
- {
- /**
- * 获取模型验证的第一个错误
- */
- public function returnFirstError()
- {
- $errors = $this->getErrors();
- if(!empty($errors)){
- $firstError = array_splice($errors, 0,1);
- $attribute = key($firstError);
- return $this->getFirstError($attribute);
- }
- return null;
- }
- }
|