In model: Put CActiveDataProvider into a variable:
<?php $dataProvider = new CActiveDataProvider($this, array( 'criteria' => $criteria, 'pagination' => array('pageSize' => 10), 'sort' => array( 'defaultOrder' => 'create_dttm DESC', ) )); ?>Check if dataprovider is empty or not:
<?php if (!isset($_REQUEST['ajax']) && $dataProvider->totalItemCount < 1) { Yii::app()->getController()->redirect(array('create')); } else { return $dataProvider; } ?>If the above code doesn't works then you can also return an empty data provider like this:
return new CActiveDataProvider($this, array('data' => array()));
No comments:
Post a Comment