I know that I can use this
public function providerAction()
{
$result = new ViewModel();
$result->setTerminal(true);
return $result;
}
But how do I pass variables to view? Before I did this
return array('items' => $items);
But now I have only one option either return array and then layout is there or return $result
then variables are not in the view.
In your example you could write like this:
public function providerAction()
{
$result = new ViewModel();
$result->setTerminal(true);
$result->setVariables(array('items' => 'items'));
return $result;
}
The previous answer works perfectly. I just want to add that instead of using setVariables
you can also pass your variables directly when instantiating the ViewModel
like this:
$result = new ViewModel(array('items' => $items));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With