简体   繁体   中英

Symfony2 routing error (parameter <x> for route <r> must match <pattern>)

I'm kind of new in Symfony2 Framework. This error take forever me to solved. I build my own project based from Jobeet tutorial. Now I've success till generate CRUD but when opening index page I got route error like this :

An exception has been thrown during the rendering of a template ("Parameter "id" for route "sifo_mst_periode_show" must match "[^/]++" ("" given) to generate a corresponding URL.") in SifoSchoolBundle:MstPeriode:index.html.twig at line 21.

This is my index.html.twig line 21 :

<td><a href="{{ path('sifo_mst_periode_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>

This is the route :

sifo_mst_periode:
    pattern:  /
    defaults: { _controller: "SifoSchoolBundle:MstPeriode:index" }

sifo_mst_periode_show:
    pattern:  /{id}/show
    defaults: { _controller: "SifoSchoolBundle:MstPeriode:show" }

And this is the routing :

SifoSchoolBundle_sifo_mst_periode:
    resource: "@SifoSchoolBundle/Resources/config/routing/mstperiode.yml"
    prefix:   /periode

This Case has been solved. The problem is Primary Key (entity.id) had NULL Value which not show in Add Form. I make all Primary Key to auto and not handle by User Form.

Thank You.

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