Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework, passing variables to view

I have a problem with displaying a view. When I pass var to view, view doesn't render.

Controller:

public function indexAction()
{
    $branchModel = new Application_Model_Branches();
    $branches = $branchModel->getAllBranches();
    $this->view->menu = $branches;
}

View (index.phtml):

<h2>Menu</h2>
<?php
    $this->htmlList($this->menu);
?>

When I try debug $branches without assign it to view, all seems to be ok, but when I try push it to view,index.phtml don't appear.

Regards

like image 597
Marek Avatar asked Dec 04 '25 15:12

Marek


1 Answers

You're just missing an echo in your code, the htmlList view helper returns a value - it doesn't echo it. Some examples of the various form view helpers can be seen here

<h2>Menu</h2>
<?php
    echo $this->htmlList($this->menu);
?>
like image 174
robjmills Avatar answered Dec 07 '25 04:12

robjmills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!