0
I use ZEND 2 and I am in the controller. I created an action to print a field (description) of a table (receipt). The point is that when I connect the controller to the view nothing appears on the site. I realized I have to set the value of the variable $saidarecibo assigning to it the value of the table field that calls Description. How do I do this?
Below is my controller:
 public function imprecibosaidaAction() {
        $data_parametro = "";
        $saidarecibo = $descricao;
        $id = (int) $this->params()->fromRoute('id', 0);
        $saidarecibo = $this->getTable('Admin\Model\Saidarecibo')->get($id);
        //$this->view->saidarecibo = $saidarecibo;
        if ($id == 0) {
            throw new \Exception("Código obrigatório");
        }
         // Turn off the layout, i.e. only render the view script.
         $viewModel = new ViewModel();
         $viewModel->setTerminal(true);
        $view = new ViewModel(array(
            'saidarecibo' => $saidarecibo,
        ));
        //return $view;
        return $viewModel;
    }
Now follow the view I created, it should print only the table field:
<?php echo $this->saidarecibo; ?>
<a style="margin-top:10px;" href="javascript:self.print()">IMPRIMIR</a>
It seems that you are trying to echo an undefined template variable, since you defined it in $viewModel, but returned $view.
– Bruno Augusto