yii1.1:$model->;save()失败,但$model->;getErrors()返回空数组
我使用的是YII1.1.16,我有如下代码:yii1.1:$model->;save()失败,但$model->;getErrors()返回空数组,yii,Yii,我使用的是YII1.1.16,我有如下代码: public function actionAdd() { $article = new Article; $article->type = $this->type; if (isset($_POST['article'])) { $article->attributes = $_POST['article']; if ($article->save()) {
public function actionAdd()
{
$article = new Article;
$article->type = $this->type;
if (isset($_POST['article'])) {
$article->attributes = $_POST['article'];
if ($article->save()) {
$this->success('saved');
} else {
var_dump($article->getErrors());
}
}
$this->render('add');
}
但是,现在
save()
失败了,但是getErrors()
返回空数组(),那么我如何知道在保存记录时失败的原因呢?您是否使用了beforeSave()
?它是否返回parent::beforeSave()
?@PrabowoMurti我找到了原因。您的想法是对的,尽管问题是我的beforevaluate()
方法没有返回parent::beforevaluate()
。非常感谢。是否在保存()之前使用了
?它是否返回parent::beforeSave()
?@PrabowoMurti我找到了原因。您的想法是对的,尽管问题是我的beforevaluate()
方法没有返回parent::beforevaluate()
。非常感谢。