Hello all,
I’m quite new to Yii and I’m still confused about CArrayDataProvider and CGridView (or CListView I guess).
Here’s my situation: I get raw data from PHPExcel, in the form of an array of arrays:
var_dump($rawData) :
array(32) { [1]=> array(5) { [0]=> string(10) "firstname1" [1]=> string(9) "lastname1" [2]=> string(15) "email@tutu.com1" [3]=> string(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' /> "company1" [4]=> NULL } [2]=> array(5) { [0]=> string(10) "firstname2" [1]=> string(9) "lastname2" [2]=> string(15) "email@tutu.com2" [3]=> string(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' /> "company2" [4]=> NULL } ...
This looks pretty straightforward to me.
So I create a CArrayDataProvider from that:
$arrayProvider=new CArrayDataProvider($rawData);
So far so good. Then I render:
$this->render('index',array(
'arrayProvider' => $arrayProvider,
),
And my view is like:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$arrayProvider,
));
I guess it should be right, but ar runtime I get a Cannot use a scalar value as an array error…
So I’m doing something wrong, but what ? Am I not using the right tool for the job ?
Thanks for the help !