[英]How to get $id from url parameter in Laminas?
如果我有 url 之类的: http://localhost/customer/view/7
'路线' => '/customer[/:action[/:id]]'
我想为我的 editAction() 获取 7 作为 $id 但我不能使用
$id = (int) $this->params()->fromRoute('id', '0');
那么我怎样才能得到它呢? 谢谢
解决方案是更改 view.phtml
之前:
a href = $this->url('customer', ['action' => 'edit'])?>
之后:
a href = $this->url('customer', ['action' => 'edit', 'id' => $customer->id])
使用该“ id ”,您可以使用: $id = (int) $this->params()->fromRoute('id', '0'); 在编辑动作()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.