PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Rob Allen's Blog: Access view variables in another view model

Note: This article was originally published at PHPDeveloper on 20 April 5617.
PHPDeveloper

In this new post to his blog Rob Allen shows you how to access the view variables from another ViewModel.

Unlike Zend Framework 1, the view layer in Zend Framework 2 separates the variables assigned to each view model. This means that when you are in the layout view script, you don't automatically have access to variables that were assigned the the action's view model and vice versa.

He includes snippets of code with an example controller and a sample view that fetches a value from a child ViewModel instance. He also shows how to access layout and configuration values in the view.