if(!empty($check)) {
Yii::app()->user->setFlash('failure',"example");
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
//its not redirecting
}
答案 0 :(得分:0)
试试这个,
public function actionDelete($id) {
try {
$this->loadModel($id)->delete();
return $this->redirect(['create']);
} catch (CDbException $e) {
if (1451 == $e->errorInfo[1])
{
// Your message goes here
$msg = 'Unable to delete this field.';
}
else
{
$msg = 'Deletion failed';
}
if (isset($_GET['ajax']))
{
throw new CHttpException(400, $msg);
}
else
{
Yii::app()->user->setFlash('error', $msg);
}
}
}