简体   繁体   中英

How to get $id from url parameter in Laminas?

if i have url like: http://localhost/customer/view/7

'route' => '/customer[/:action[/:id]]'

I want to get 7 as $id for my editAction() but i cant use

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

So how can i get it? Thank you

The solution is change the view.phtml

Before :

a href = $this->url('customer', ['action' => 'edit'])?>

After :

a href = $this->url('customer', ['action' => 'edit', 'id' => $customer->id])

With that ' id ' you can use: $id = (int) $this->params()->fromRoute('id', '0'); in editAction()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM