php - how to get table id in zf2? -


i make view file in zf2.in pass id controller.

how id in controller?

here showaction code want id:

public function showaction() {                $id = (int) $this->params()->fromroute('id', 0);     if (!$id) {         return $this->redirect()->toroute('calendar', array(             'action' => 'create'         ));     }                } 

and here index.phtml on pass id show controller:

<table class="table"> <tr>     <th>calendar name</th>     <th>description</th>     <th>actions</th> </tr> <?php foreach ($calendars $key => $value) :  ?> <tr>     <td>         <a href="<?php echo $this->url('calendar',array('action'=>'show', 'id' => $this->escapehtml($value['_id'])));?>">                 <?php echo $this->escapehtml($value['title']);?>         </a>     </td>     <td><?php echo $this->escapehtml($value['description']);?></td>     <td>         <a href="<?php echo $this->url('calendar',             array('action'=>'settings', 'id' => $this->escapehtml($value['_id'])));?>">settings</a>         <a href="<?php echo $this->url('calendar',             array('action'=>'delete', 'id' => $this->escapehtml($value['_id'])));?>">delete</a>     </td> </tr> <?php endforeach; ?> </table>     

you gettting id fro route through line in controller

$id = (int) $this->params()->fromroute('id', 0); 

if want, can access following line

$id = (int)$this->params('id'); 

if echo $id, should id value


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -