Flash Message

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:


public function actionDelete($id)




	// 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)');






		} else {				$model=$this->loadModel($id);

			$model->edt = date("Y-m-d H:i:s");




	// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser


		$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));



		throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');



<?php if(Yii::app()->user->hasFlash(‘success’)):?>

&lt;div class=&quot;flash-error&quot;&gt;

    &lt;?php echo Yii::app()-&gt;user-&gt;getFlash('success'); ?&gt;


<?php endif; ?>

You need to use ‘ajaxUpdate’ attribute of TbGridView.

‘ajaxUpdate’ calls a division of flash message after an ajax function call of TbGridView.


<div id="flash-msgs"><?php 

        if(Yii::app()->user->hasFlash("success")) {        

                ?><div class="flash-error"><?php         

                        echo Yii::app()->user->getFlash("success"); 



        if(Yii::app()->user->hasFlash("error")) {        

                ?><div class="flash-success"><?php         

                        echo Yii::app()->user->getFlash("error"); 




$this->widget('bootstrap.widgets.TbGridView', array(

        'type' => 'striped bordered',

        'id' => 'category-grid',

        'ajaxUpdate' => 'flash-msgs',

        'dataProvider' => $model->search(),

        'template' => "{items}",

        'filter' => $model,

        'columns' => array(




Let me know if any concern/concern regarding this.


Saurabh Dhariwal