經過表單模型作接口,驗證返回的錯誤明確錯誤信息以下: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()會獲取到詳細的錯誤信息以方便一下步的調試接口