我在我的模型中创建了一个beforeSave方法(扩展了GXActiveRecord),if isNewRecord永远不会被触发.我的beforeSave()被调用了.
当我打印$ this-> isNewRecord变量时,它是假的.该变量何时设置为false?我很确定这是新的
public function beforeSave(){
if(parent::beforeSave())
{
if($this->isNewRecord){
$this->setAttribute('doc_status','new');
print "something";
}else{
$this->setAttribute('doc_status','updated');
}
return true;
} else { return false;
}
Run Code Online (Sandbox Code Playgroud)