/**
- 提取rules规则验证错误的信息
- @param [type] $model
@return void
*/
public static function getModelError($model) {
if(empty($model)) return true;
$errors = $model->getErrors(); //得到所有的错误信息if(!is_array($errors)){ return true; } $firstError = array_shift($errors); if(!is_array($firstError)) { return true; } return array_shift($firstError);
}
调试的过程中通过打断点到$this->save() load() validate(),然后查看获取的
$this->errors、 $model->getErrors()会获取到详细的错误信息以方便一下步的调试
原文:https://blog.51cto.com/13238147/2397108