Hi,

I am having trouble using Zend_Dojo_Data on a project.   I know this
question has been answered before
(http://www.nabble.com/RFC:-Zend_Dojo_Data---associative-arrays-td23175415.html
and
http://www.nabble.com/How-to-correctly-use-Zend_Dojo_Data-td19149257.html)
but I still can't seem to figure out what's wrong.  

Instead of populating the data when I instantiate the ZDD object, I am
looping through and array of JSON strings and adding each item via a call to
addItem().  Before calling addItem I use Zend_Json::decode to convert the
JSON into an array:

$ZDD_ListObj = new Zend_Dojo_Data(); 
$ZDD_ListObj->setIdentifier('orgid');
$ZDD_ListObj->setLabel('MyLabel');
             
//add each item to the Zend_Dojo_Data object 
for ($i=0; $i<$arraySize; $i++){
    $decodedJson = Zend_Json::decode($array[$i]);
    $ZDD_ListObj->addItem($decodedJson);
}

This results in the following:

Error: Only arrays and objects may be attached

#0 /usr/share/php/ZendFramework-1.8.1/library/Zend/Dojo/Data.php(114):
Zend_Dojo_Data->_normalizeItem(' {"ver": 1, "or...', NULL)
#1 /home/account/application/default/controllers/OrgsController.php(78):
Zend_Dojo_Data->addItem(' {"ver": 1, "or...')

I have verified that $decodedJson is in fact a valid array by doing a
print_r on the array:

Array
(
    [ver] => 1
    [orgid] => 1
    [icon] => http://server.com/images/nationaal.png
    [title] => My Title
    [sum] => Summary text
)

What am I doing wrong?  I'm beginning to wonder if it's a PHP version
compatibility version.  This exact code works fine on a PHP 5.1.6 install
but the error happens on a PHP 5.2.1 install.  Is this a
bug/incompatibility, or am I doing something wrong?
-- 
View this message in context: 
http://www.nabble.com/Zend_Dojo_Data---Only-arrays-and-objects-may-be-attached-tp23568746p23568746.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to