Код: Выделить всё
protected function beforeSave(){
if(!parent::beforeSave())
return false;
if(($this->scenario=='insert' || $this->scenario=='update') &&
($document=CUploadedFile::getInstance($this,'document'))){
$this->deleteDocument(); // старый документ удалим, потому что загружаем новый
$this->document=$document;
$this->document->saveAs(
Yii::getPathOfAlias('webroot.media').DIRECTORY_SEPARATOR.$this->document);
}
return true;
}
Код: Выделить всё
if(!parent::beforeSave())
return false;