php - On actionDelete how we redirect on same page with flash in yii -
if(!empty($check)) { yii::app()->user->setflash('failure',"example"); $this->redirect(isset($_post['returnurl']) ? $_post['returnurl'] : array('admin')); //its not redirecting }
try this,
public function actiondelete($id) { try { $this->loadmodel($id)->delete(); return $this->redirect(['create']); } catch (cdbexception $e) { if (1451 == $e->errorinfo[1]) { // message goes here $msg = 'unable delete field.'; } else { $msg = 'deletion failed'; } if (isset($_get['ajax'])) { throw new chttpexception(400, $msg); } else { yii::app()->user->setflash('error', $msg); } } }
Comments
Post a Comment