2016-06-11 52 views
0
if(!empty($check)) { 
    Yii::app()->user->setFlash('failure',"example"); 
    $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); 
    //its not redirecting 
} 
+1

您正在使用yii1或yii2? – scaisEdge

回答

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); 
        } 
    } 
}