I just added this into my model but it doesn't work :
protected function onBeforeDelete($event) {
parent::onBeforeDelete($event);
$this->rootPath = Yii::app()->getBasePath().'/..';
unlink($this->rootPath.$this->thumb_url);
unlink($this->rootPath.$this->image_url);
}
I think i need to initiaize a new event from the controller.
My delete action in controller is the default delete action :
public function actionDelete($id) {
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl'])?$_POST['returnUrl']:array('admin'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
I get a blank page because of $event was not initialized.
Should i have to initialize it into the controller or into the model?
Any example please ?

Help















