SonataAdminBundle: List view crashes dev-master
Some of my list views crash with the following error:
[2015-05-05 09:56:15] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: “An exception has been thrown during the rendering of a template (“Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Foo\Bundle\BarBundle\Entity\BarTranslation’ does not have a method ‘_action’”) in “SonataAdminBundle:CRUD:base_list_inner_row.html.twig” at line 18.” at /var/www/app/cache/dev_mobile/classes.php line 4791 {“exception”:“[object](Twig_Error_Runtime%28code: 0%29: An exception has been thrown during the rendering of a template %28"Warning: call_user_func_array%28%29 expects parameter 1 to be a valid callback, class) in "SonataAdminBundle:CRUD:base_list_inner_row.html.twig" at line 18. at /var/www/app/cache/dev_mobile/classes.php:4791, Symfony\Component\Debug\Exception\ContextErrorException(code: 0): Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Foo\Bundle\BarBundle\Entity\BarTranslation’ does not have a method ‘_action’ at /var/www/vendor/knplabs/doctrine-behaviors/src/Model/Translatable/TranslatableMethods.php:144)”} []
I am using sonata with the following setup:
"sonata-project/core-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/datagrid-bundle": "dev-master",
"sonata-project/easy-extends-bundle": "dev-master",
"sonata-project/classification-bundle": "dev-master",
"sonata-project/user-bundle": "dev-master",
"sonata-project/media-bundle": "dev-master",
"sonata-project/news-bundle": "dev-master",
and
"knplabs/doctrine-behaviors": "~1.0",
for translation.
If I remove the “_action” section in configureListFields() the problems seems to be resolved:
->add('_action', 'actions', [
'actions' => [
'edit' => [],
'delete' => [],
]
])
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20 (13 by maintainers)
Hi, If someone has the same problem (I just had it) the following code will throw the same exception:
To fix, you need to specify “actions” as type (by default with make it will create as null):