SonataDoctrineORMAdminBundle: error with link rendering

after commit ec1949a98c1dddf79533db0b272f9573ad6e63ac I have such problem:

An exception has been thrown during the rendering of a template 
("Parameter "id" for  route 
"ru__RG__admin_topes_website_company_edit" 
must match "[^/]++" ("" given) to 
generate a corresponding URL.") in 
SonataDoctrineORMAdminBundle:CRUD:list_orm_many_to_one.html.twig at line 16.

It occurs when is the relationship between the User and the Company (many-to-one)

and i want to show company field in admin list

 $listMapper
            ->addIdentifier('username') 
            ->add('company', null, array( )  )

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 25 (9 by maintainers)

Most upvoted comments

@mattchete nope 😦

In my case i’ve got almost same problem:

An exception has been thrown during the rendering of a template (ā€œParameter ā€œidā€ for route ā€œadmin_sonata_media_media_editā€ must match ā€œ[^/]++ā€ (ā€" given) to generate a corresponding URL.") in ā€œSonataMediaBundle:Form:media_widgets.html.twigā€.

My entities:

  • Survey
  • SurveyQuestion (has sonata media image). It is many-to-one to Survey

So when I’m creating Survey, I add one SurveyQuestion, attach image with sonata-media, and then I want to add another one SurveyQuestion, but get this exception.

It is about the Image doesn’t have an id, so method generateObjectUrl(ā€˜edit’, value) from SonataMediaBundle:Form:media_widgets.html.twig line 6 crushes.

So I solved this partially with rearranging default template, like it is said in sonata docs.

I’ve just added this to my config.yml:

    form:
        resources:
            - 'AppBundle:SurveyQuestionAdmin:media_widgets.html.twig'

And my new template has just one more check to render the image’s link and thumb - ā€œand value.idā€ on lines 4 and 22:

//media_widgets.html.twig
{% if value is not empty and value.providerReference and value.id %}
...
{% if value is not empty and value.providerReference and value.id %}

Now there is no exception, but still have problem: non saved images attached to questions disappear after adding new SurveyQuestion.

So it’s not a solution, but I’m on my way )