500 error when using sonata_media_type as a 1:N via a sonata_type_collection field 500 error when using sonata_media_type as a 1:N via a sonata_type_collection field symfony symfony

500 error when using sonata_media_type as a 1:N via a sonata_type_collection field


This issue seems to be related to this question in the sonata-users google group.

The problem seems to be that the media-type's label isn't passed to the template which results in an error when invoking the translator/calling the trans method in the template here:

{{ nested_field.vars['sonata_admin'].admin.trans(nested_field.vars.label) }}

in SonataDoctrineORMAdminBundle/Resources/views/CRUD/edit_orm_one_to_many.html.twig.

I suggest you first try to add a label to your form-type.

'label' => 'Media' 

If that doesn't work you could fork the repository and clone it afterwards:

git clone https://github.com/yourusername/SonataDoctrineORMAdminBundle.git

then create a new branch using the 2.2.3 tag:

git branch bugfix-2.2.3 2.2.3git checkout bugfix-2.2.3

now change line 30 in edit_orm_one_to_many.html.twig to (or remove it completely which would result in the labels not being rendered at all)

{% if nested_field.vars.label %}    {{ nested_field.vars['sonata_admin'].admin.trans(nested_field.vars.label) }}{% endif %}

Afterwards commit your changes and ...

... either overwrite the tag (please note that tags should normally never be overwritten )

git commitgit tag -f 2.2.3

... or (better) create an alias in your composer.json

"require": {    "sonata/doctrine-orm-admin-bundle" : "bugfix-2.2.3#<commit-sha> as 2.2.3"

then add this to your composer.json:

"repositories": [    { "type": "vcs", "url": "http://github.com/yourusername/doctrine-orm-admin-bundle"}],

afterwards run

composer update sonata/doctrine-orm-admin-bundle

I'm not sure if it helps but the many-to-many support for inline-editing has been added in this commit. You could try changing your association to many-to-many and test wether the exception disappears.

If that doesn't work either please report back and i will dig deeper into this.