views:
[<?php echo CHtml::linkButton('删除歌曲',array('submit'=>array('delete','id'=>$music->musicId),'confirm'=>'你确定要删除吗?')); ?> ]
MusicController:
public function actionDelete() { if (Yii::app ()->request->isPostRequest) { // we only allow deletion via POST request $this->loadMusic()->delete (); $this->redirect ( array ('list' ) ); } else throw new CHttpException ( 500, 'Invalid request. Please do not repeat this request again.' ); } */ public function loadMusic($id = null) { if ($this->_music === null) { if ($id !== null || isset ( $_GET ['id'] )) $this->_music = Music::model ()->findByPk ( $id !== null ? $id : $_GET ['id'] ); if ($this->_music === null) throw new CHttpException ( 500, 'The requested music does not exist.' ); } return $this->_music; }
为什么我一直删除不成功,在model 的beforeDelete和afterDelete里都可以删除成功了,可就是actionDelete删除不了,但依然会执行到 $this->redirect ( array ('list' ) );这个语句。
哪个可以帮忙?谢谢!