开发者

Problem with passing Object data to view in PartialLoop

Message: PartialLoop helper requires iterable data

Stack trace:
#0 [internal function]: Zend_View_Helper_PartialLoop->partialLoop('partials/ListaK...', Object(Model_Klasy))
#1 C:\xampp\php\PEAR\Zend\View\Abstract.php(342): call_user_func_array(Array, Array)
#2 [internal function]: Zend_View_Abstract->__call('partialLoop', Array)
#3 C:\xampp\htdocs\inzynierka\application\views\scripts\klasy\lista.phtml(9): Zend_View->partialLoop('partials/ListaK...', Object(Model_Klasy))
#4 C:\xampp\php\PEAR\Zend\View.php(108): include('C:\xampp\htdocs...')
#5 C:\xampp\php\PEAR\Zend\View\Abstract.php(880): Zend_View->_run('C:/xampp/htdocs...')
#6 C:\xampp\php\PEAR\Zend\Controller\Action\Helper\ViewRenderer.php(897): Zend_View_Abstract->render('klasy/lista.pht...')
#7 C:\xampp\php\PEAR\Zend\Controller\Action\Helper\ViewRenderer.php(918): Zend_Controller_Action_Helper_ViewRenderer->renderScript('klasy/lista.pht...', NULL)
#8 C:\xampp\php\PEAR\Zend\Controller\Action\Helper\ViewRenderer.php(957): Zend_Controller_Action_Helper_ViewRenderer->render()
#9 C:\xampp\php\PE开发者_Go百科AR\Zend\Controller\Action\HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#10 C:\xampp\php\PEAR\Zend\Controller\Action.php(523): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#11 C:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('listaAction')
#12 C:\xampp\php\PEAR\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#13 C:\xampp\php\PEAR\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#14 C:\xampp\php\PEAR\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#15 C:\xampp\htdocs\inzynierka\public\index.php(26): Zend_Application->run()
#16 {main} 

I'm trying to pass this data:

    object(Model_Klasy)#76 (4)
{ 
   ["_id":"Model_Klasy":private]=> int(1) 
   ["_rokRozpoczecia":"Model_Klasy":private]=> int(2010) 
   ["_nazwa":"Model_Klasy":private]=> string(2) "1a" 
   ["_Wychowawca":"Model_Klasy":private]=> int(9) 
} 

Here is Action:

$modelLista = new Model_KlasyMapper();
$this->view->listaKlas = $modelLista->listaKlas();

And View:

echo $this->partialLoop('partials/ListaKlas.phtml', $this->listaKlas);

How solve this problem ? Probably it is easy but I'm tired :/


Your object needs to support a an implement an iterable interface like ArrayAccess or IteratorAggregate (Though i think even something as simple as Traversable will work). Or you could make all the members public (shudder).


All it was wrong because of one bracer :) I hate it when miss something :P After it I can display it after little modification:

   <?php foreach ($this->listaKlas as $dane) :  ?>
                <td><?php echo $dane->getNazwa(); ?></td>
                <td><?php echo $dane->getRokRozpoczecia(); ?></td>
                <td><?php echo $dane->getWychowawca(); ?></td>
etc.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜