You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
584 B

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Steven
  5. * Date: 2017/10/13
  6. * Time: 12:12
  7. *
  8. * 用于不继承自 \yii\db\ActiveRecord的Model,不做表是否存在的判断
  9. */
  10. namespace common\models;
  11. use yii\base\Model;
  12. class commonModel extends Model
  13. {
  14. /**
  15. * Author:Steven
  16. * Desc:验证失败后取第一条错误信息
  17. * @return string
  18. */
  19. public function getErrorMsg(){
  20. $errors = $this->getFirstErrors();
  21. $str = [];
  22. foreach ($errors as $error) {
  23. $str[] = $error;
  24. }
  25. return implode(';', $str);
  26. }
  27. }