fetchit-21
There is a Yii error I come across every now and again, and each time it stumps me.
If you ever get SomeModel.id not defined error when trying to put your dataprovider results into a cgridview or similar then it’s likely because
1) Your model doesn’t have an id column, it might use file_id or user_id etc instead and
2) You haven’t defined which other column should be used.
We do this using what’s known as keyField:
new CArrayDataProvider($users, array('keyField' => 'user_id'));
new CSqlDataProvider($users, array('keyField' => 'user_id'));
Thanks for sharing this piece of code, it helped me to solve a problem I had with CGridView and CArrayDataProvider.
Cheers.
Posted by Joaquin on August 9th, 2011.
Thanks, solved my problem
Posted by Joris on January 14th, 2012.