0
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\PEAR\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 :/

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

7 Comments

Implement all the methods of one of the appropriate interfaces and add the implementation tot he class like: class Model_Klassy implements ArrayAccess { /* class body */ } Check out this DevZone Article for a crash course: devzone.zend.com/article/2565
Fatal error: Class Model_KlasyMapper contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (ArrayAccess::offsetExists, ArrayAccess::offsetGet, ArrayAccess::offsetSet, ...) in C:\xampp\htdocs\inzynierka\application\models\KlasyMapper.php on line 48
Umm yeah.. you have to implement those methods man... you can just declare the interface and then it works...
I am confused. I start with Zend 2 months ago and also learning OOPHP :/ Can u help me more ?
er cant not can :-) Read the artical i posted link to... Whatever interface you choose to use you need to implement ALL or its methods. The documentation for the given interface will tell you what each method is supposed to do - you just need to right the code to make it do that. Heres another good one specifically for ArrayAccess if thats what you want to use: phpro.org/tutorials/Introduction-to-SPL-ArrayAccess.html
|
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.