I use ZEND 2 and I'm in the controller. There I created an action to print a field (description) of a table (received). The issue is that when I connect the controller with the view nothing appears on the site. From what I've realized I have to set the value of the variable $saidarecibo
by assigning it the value of the field of the table 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>