public function beforeSave() { if ($this->hasAttribute('date') && !$this->date) { $this->date = new CDbExpression('NOW()'); } return parent::beforeSave(); }