要爲編輯表單
添加到您的管理類添加一個動作:
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('My action', array('uri' => 'http://google.com?id=' . $id));
}
這將爲像/管理/ ACME /視頻/ X /編輯/動作左側菜單。擁有當前項目的ID可讓您構建任何自定義網址。
要添加列表中選擇操作: 在您的管理文件中添加
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('_action', 'actions', array(
'actions' => array(
'act' => array('template' => 'AcmeBundle:Video:my_temp.html.twig'),
)
))
;
}
這將增加一列的鏈接,那麼你就需要爲你列一個模板,像
<a href="{{ admin.generateObjectUrl('delete', object) }}" class="delete_link" title="{% trans from 'SonataAdminBundle' %}action_delete{% endtrans %}">
<img src="{{ asset('bundles/sonataadmin/famfamfam/delete.png') }}" alt="{% trans from 'SonataAdminBundle' %}action_delete{% endtrans %}" />
</a>
所有示例均取自您提供的鏈接。希望它有幫助
'configureSideMenu'已棄用。改用'configureTabMenu'。 – sergekv 2015-10-09 12:17:43