check for isNewRecord should take place after beforeSave()!

I noticed that if you want to create a new record in the DB each time you call save using a behavior, the only way is to do this within afterValidate, like




public function afterValidate() {

     $this->owner->setIsNewRecord(TRUE)  ;

     $this->owner->id = NULL ;

}



Although this work great, until you call save without validation:




....

$model->save(false) ;

$model->title = 'barfoo' ;

$model->save(false) ;



The problem is that CActiveRecord does the isNewRecord-test after afterValidation() and before beforeSave(). I would say that this test should be after beforeSave()!

Cheers