Question

I am having a problem with a findAll in symfony 2

I have an entity Picture and an entity Collection. I also have a reloation ManyToOne on picture target Collection.

In my controller i have this:

$em = $this->getDoctrine()->getManager();

    $entities = $em->getRepository('AppPictureBundle:Collection')->findAll();

    return array(
        'entities' => $entities,
    );

and i am having this error

An exception has been thrown during the rendering of a template ("Parameter "id" for route "picture_show" must match "[^/]++" ("" given) to generate a corresponding URL.") in C:\wamp\www\band\src\App\PictureBundle/Resources/views/Picture/index.html.twig at line 21.

when i remove the links in the index file that are not working(because they dont have the id) my page is generated correctly with all the fields from my db except for the ids (which are also supposed to be printed)

My controller is the same controller that of doctrine:generate:crud

I did the same thing for my entity Collection and it works perfectly so I dont understant why i am having all the fields except the id.

Just in case: https://github.com/KhalidSookia/band

Was it helpful?

Solution

For some reason one of your entities doesn't have an ID and it's required to generate a URL using the picture_show route.

After a quick code scan I can't find a reason why an ID might be missing. It might have something to do with the inheritance hierarchy the Picture is involved in. Check the database to confirm there are indeed some missing IDs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top