0
大家好我目前正在使用zend 2.3。在列出学生的同时,我正在尝试建立链接,以便显示关于选定人员的详细信息。我的问题是,我无法将选定的ID传递给模块控制器中的动作。下面是coresponds链接我的看法代码:无法将参数从视图传递到控制器
<a href="<?php echo $this->url('admin' ,
array('controller'=>'Admin', 'action'=>'viewstudent', 'ID' => $student->ID))."/admin/viewstudent";?>">detales</a>
和动作控制器
public function viewstudentAction()
{
$id = (int) $this->params()->fromRoute('ID', 0);
echo $id;
//echo var_dump($id);
return new ViewModel(array(
'students' => $this->getStudentTable()->viewstudent($id),
));
}
然后我var_dump $id
变量它显示为0那么,什么是做到这一点的正确方法是什么?
我已经编辑在href的这样的代码
<a href="<?php echo $this->url('admin/default' ,
array('controller'=>'Admin', 'action'=>'viewstudent', 'id' => $student->ID));?>">Просмотр</a>
,并解析到此:
<a href="/disability/public/admin/Admin/viewstudent">Просмотр</a>
网址是
http://localhost:8080/disability/public/admin/Admin/viewstudent
URL是
http://localhost:8080/disability/public/admin/Admin/viewstudent
问题是相同的ID没有通过
你有路由设置的例子向上? 看这个,URL会导致类似于/ Admin/viewstudent/[ID]/admin/viewstudent的东西? – Rachel
@Rachel感谢评论我编辑了一个href部分问题仍然存在。 –