Das hinzufügen von Aktion in SonataAdminBundle
Ich versuche, um eine Aktion in sonata admin bundle. Ich änderte meine Admin-Klasse mit :
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('id')
->add('name')
//add custom action links
->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'calculate' => array('template' => 'myappMyBundle:Admin:list__action_calculate.html.twig'),
'edit' => array(),
)
))
;
}
und
protected function configureSideMenu(MenuItemInterface $menu, $action, Admin $childAdmin = null)
{
if (!$childAdmin && !in_array($action, array('edit'))) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
$menu->addChild('calculate', array('uri' => 'http://google.com?id=' . $id));
}
und legen Sie ein template namens Liste__action_berechnen.html-Code.Zweig in src/myapp/MyBundle/Resources/views/Admin/:
{% if admin.isGranted('EDIT', object) and admin.hasRoute('edit') %}
<a href="{{ admin.generateObjectUrl('calculate', object) }}" class="calculate_link" title="{{ 'action_calculate'|trans({}, 'SonataAdminBundle') }}">
<img src="{{ asset('bundles/sonataadmin/famfamfam/page_white_edit.png') }}" alt="{{ 'action_calculate'|trans({}, 'SonataAdminBundle') }}" />
</a>
{% endif %}
Aber ich habe diesen Fehler von symfony :
An exception has been thrown during the rendering of a template
("unable to find the route `mysite.mybundle.admin.myentity.calculate`")
in "SonataAdminBundle:CRUD:list.html.twig"
Was habe ich verpasst ?
Gibt es einen Hinweis in der Dokumentation, als diese Seite von der Doc.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Habe es endlich !
In der admin-Klasse :
und im admin-controller :
und in /src/mysite/mybundle/Resources/views/CRUD :