When Carraydataprovider Empty Get This Error

array_slice() expects parameter 1 to be array, null given

what is the solution for that????


Please give us the part of code that causing the error

// this is the data provider

$arrayDataProvider = new CArrayDataProvider(Yii::app()->session->get(‘temp_org_contact’), array(

              'id' => 'id',

              'sort' => array(

                  'attributes' => array(

                      'value', 'type',



              'pagination' => array(

                  'pageSize' => yii::app()->params['orgPage'],



then i render it

$controller->render(‘form’, array(

      'model' => $model,

      'dataProvider' => $dataProvider,

      'arrayDataProvider' => $arrayDataProvider,




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

   'dataProvider' =&gt; &#036;arrayDataProvider,

   'id' =&gt; 'contacts-grid',

   'type' =&gt; 'striped bordered condensed',

   'summaryText' =&gt; '',

   'columns' =&gt; array(


           'name' =&gt; 'type',

           'type' =&gt; 'raw',

           'value' =&gt; 'CHtml::encode(&#036;data[&quot;type&quot;])'



           'name' =&gt; 'value',

           'type' =&gt; 'raw',

           'value' =&gt; 'CHtml::encode(&#036;data[&quot;value&quot;])',



           'class' =&gt; 'bootstrap.widgets.TbButtonColumn',

           'template' =&gt; '{delete}',

           'htmlOptions' =&gt; array('style' =&gt; 'width: 50px'),

           'buttons' =&gt; array(

               'delete' =&gt; array('url' =&gt; 'Yii::app()-&gt;createUrl(&quot;organizations/organization/DeleteContactList&quot;, array(&quot;id&quot;=&gt;&#036;data[&quot;id&quot;]))'),






this is working if at least one record present

but when it is empty is gives ths error

thanks :)

i think you defind the blank array before code start…


i hope it’s works…

still get the error when crash clear


in your code when page render what is ?

'dataProvider' => $dataProvider,

can you post the full code?

hi ankit i got the point from your post

$sessonArr = array();

  (Yii::app()-&gt;session-&gt;get('temp_org_contact')) ? &#036;sessonArray = Yii::app()-&gt;session-&gt;get('temp_org_contact') : &#036;sessonArray = &#036;sessonArr;

i did it thanks


cool… :rolleyes: