经过表单模型作接口,验证返回的错误明确错误信息以下:ide
/**this
- 提取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);}code
调试的过程当中经过打断点到$this->save() load() validate(),而后查看获取的
$this->errors、 $model->getErrors()会获取到详细的错误信息以方便一下步的调试接口