I just started with ZEND Framework Forms. I want to make an easy guestbook in my first abstract project. For my guestbook i use 5 colomns in table “gastenboek”. There is also one datetime field. I want to show the data in the Views like something in this order:
DATE_FORMAT(gastenboek.date,’%d-%m-%Y %H:%i’) AS gastenboek_date
How can i do this in Zend framework, do i have to adjust something in the controller before fetchall?
Or can i do something after that, before i assign the array to the Views?
My controller:
class GastenboekController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$entries = new Application_Model_DbTable_Gastenboek();
$test = $entries->fetchAll();
$paginator = Zend_Paginator::factory($test);
$paginator->setItemCountPerPage(3);
$paginator->setCurrentPageNumber($this->_request->getParam('page'));
$this->view->assign('entries' ,$paginator);
}
}
And Smarty Views gastenboek\index.tpl
<h2>Gastenboek</h2>
<table>
{foreach from=$entries item=entry}
<tr>
<td><strong>Naam: {$entry.naam} {$entry.date} </strong></th>
</tr>
<tr>
<td>{$entry.bericht}</td>
</tr>
{/foreach}
</table>
Greetz Eric
If your date formatting is view specific, I would do it in the view itself: