2
votes

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
1
make sure entity.id have some value - xiidea
How do you initialize entity? If its in a loop make sure you check if entity.id is empty or null! - PCoder
@PCoder : Atually im using generate:crud command based Jobeet tutorial day 3 intelligentbee.com/blog/2013/08/09/… Its auto generated. - Jun Rikson
How about placing an if condition to check whether its empty or null? - PCoder
@PCoder : Its NULL. Seems the form which auto generated not put PK in the form. Normally in PHP, I do input manually the Primary Key. Im sorry if this is become out of topic. But am I must change all PK to auto? so it will be generated without interaction from user instead make new field as Code for user interface. - Jun Rikson

1 Answers

3
votes

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.