Hi guys,
I want to show flash message after ajax request on bootstrap.widgets.TbGridView delete link.When user wants to delete item, i then check if that record has some child records then I set flash message but that is not showing in view. following is my code:
CONTROLLER.PHP
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
// Check if product type is connected with other module
$aCheckDeptEmp = array();
$aCheckLink = Products::model()->findAll('ptype=:pt', array(':pt'=>$id));
if(count($aCheckLink) > 0) {
Yii::app()->user->setFlash('success','PRODUCT TYPE linked with product(s)');
/*$this->render('admin',array(
'model'=>ProductType::model(),
));//*/
//$this->actionAdmin();
//return;
} else { $model=$this->loadModel($id);
$model->edt = date("Y-m-d H:i:s");
$model->save(false);
//$this->loadModel($id)->delete();
}
// 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
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
VIEW.PHP
<?php if(Yii::app()->user->hasFlash(‘success’)):?>
<div class="flash-error">
<?php echo Yii::app()->user->getFlash('success'); ?>
</div>
<?php endif; ?>