0
我有傳值從控制器的麻煩Zend Framework中查看3.如何從Controller傳遞值以在zend框架3中查看?
我試過如下:試圖索引頁打印$msg
,它是有索引頁空值,但在add.phtml
它顯示的信息正確。
AlbumController.php
public function addAction()
{
$form = new AlbumForm();
$msg ='hello';
print_r($msg);
$form->get('submit')->setValue('Add');
$request = $this->getRequest();
if ($request->isPost()) {
$album = new Album();
$form->setInputFilter($album->getInputFilter());
$form->setData($request->getPost());
$add = $request->getPost('submit', 'Cancel');
if ($form->isValid()) {
$album->exchangeArray($form->getData());
$this->table->saveAlbum($album);
//$this->flashMessenger()->addSuccessMessage('<b>Added Successfully...</b>');
//$successMessages = $this->flashMessenger()->hasSuccessMessages() ? $this->flashMessenger()->getSuccessMessages() : null;
//print_r($successMessages);exit;
} else {
//$this->flashMessenger()->addMessage('<div class="alert alert-danger" role="alert"><b>Failed to Add...!!</b></div>');
}
return $this->redirect()->toRoute('album');
}
//return array('form' => $form,'success' => $successMessages);
$view = new ViewModel(array('message' => $msg, 'form' => $form));
return $view;
}
index.phtml
<?php
echo($this->msg ? 'true' : 'false');
?>