9
소나타 관리 번들에 액션을 추가하려고합니다. 나는 내 관리 클래스를 변경 :SonataAdminBundle에서 액션 추가하기
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(),
)
))
;
}
및
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));
}
및 SRC/MyApp를/MyBundle/자원/조회/관리에 list__action_calculate.html.twig라는 템플릿/넣어 :
{% 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 %}
을
하지만 난 심포니에서이 오류를 가지고 :
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"
,536을
나는 무엇을 놓쳤는가? 이 페이지의 Doc보다 단서가 있습니까?
공식 문서 : [배치 작업] (http://sonata-project.org/bundles/admin/2-2/doc/reference/batch_actions.html) –
새 문서 이동 od, 업데이트 주셔서 감사합니다. – user1254498