hi everybody !
I want to have a grid which display all data from the table "Personne" which have the ID of the event in to FK column.
So what I did. In my controller I get the list of person and I sent it to my view.
$listPersonne = Personne::searchByEvent($idEvent);
$this->render("viewInscriptions",array(
'listPersonne'=>$listPersonne,
'idEvent'=>$idEvent,
));
it works but all data are in an array.
so in my view, I transform the data to have a dataprovider for my CGridView.
$dataProvider = new CArrayDataProvider('Personne');
$dataProvider->setData($listPersonne);
and then I try to list the object :
$this->widget('zii.widgets.grid.CGridView', array(
//'id'=>'personne-grid',
'dataProvider'=>$dataProvider,
//'filter'=>$listPersonne,
'columns'=>array(
'Id_Personne',
array(
'class'=>'CButtonColumn',
),
),
));
an I have this error :
Php notice
- Trying to get property of non-object
D:\ ... \yii\framework\base\CComponent.php(612) : eval()'d code(1)
So I wonder if I take the good way to do this?
and if yes, how to solve the error?
More information :
Var_dump on dataprovider :
object(CArrayDataProvider)#23 (11) {
["keyField"]=> string(2) "id"
["rawData"]=> string(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' /> "Personne"
["caseSensitiveSort"]=> bool(true)
["_id":"CDataProvider":private]=> NULL
["_data":"CDataProvider":private]=> array(1) {
[0]=> array(32) {
["Id_Personne"]=> string(1) "1"
["DateInscription"]=> string(10) "2014-03-10"
["Statut"]=> string(10) "pr�inscrit"
["Politesse"]=> string(1) "0"
["Nom"]=> string(1) "0"
["Prenom"]=> string(1) "0"
["Adr_Numero"]=> string(1) "0"
["Adr_Boite"]=> NULL
["Adr_Rue"]=> string(1) "0"
["Adr_CodePostal"]=> string(1) "0"
["Adr_Localite"]=> string(1) "0"
["Adr_Pays"]=> string(1) "0"
["Email"]=> string(1) "0"
["TelFixe"]=> NULL ["Gsm"]=> NULL
["TelFax"]=> NULL
["Organisation"]=> string(1) "0"
["Fonction"]=> string(1) "0"
["AdrFacture"]=> NULL
["NumTVA"]=> NULL
["CommStructuree"]=> string(1) "0"
["AttestationPresence"]=> NULL
["Recu"]=> NULL ["Facture"]=> NULL
["Act_Statut"]=> NULL
["Act_Prix"]=> NULL
["Dvd_Statut"]=> NULL
["Dvd_Prix"]=> NULL
["Remarque"]=> NULL
["PrixTot"]=> string(4) "0.00"
["Id_Evenements"]=> string(1) "1"
["Id_Qualite"]=> string(1) "1"
}
}
["_keys":"CDataProvider":private]=> NULL
["_totalItemCount":"CDataProvider":private]=> NULL
["_sort":"CDataProvider":private]=> NULL
["_pagination":"CDataProvider":private]=> NULL
["_e":"CComponent":private]=> NULL
["_m":"CComponent":private]=> NULL
SOLUTION : Add the id column name of the object to the keyfield . (not ‘id’ by default).
$dataProvider = new CArrayDataProvider(‘Personne’, array(‘keyField’=>‘Id_Personne’,
'data'=>$listPersonne,
'pagination'=>array('pageSize'=>'20')));
But I still can’t add
array(
'class'=>'CButtonColumn',
),
In the columns to have button.