control中会抛出一个exception:
ProductControl.php:
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
try{
$this->loadModel($id)->delete();
}
catch(Exception $e)
{
throw new CHttpException(400,'你试图删除的产品存在版本,系统不能删除该产品,如果你需要删除该产品,请先清空该产品的其他信息,然后重新执行删除操作。');
//throw new CHttpException(500);
}
// 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
{
if(!isset($_GET['Product']))
{
$model=$this->loadModel($id);
$this->render('delete',array(
'model'=>$model,
));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
}
页面上会弹出一个alert对话框? 如何才能定制这个对话框?
查到资料看到说,在views/system/下建立error400.php的视图就可以定义控制这个exception但是不响应。