简体   繁体   English

生成路由到其他管理类

[英]generate route to other admin class

I search over google for a long time, but I don't find any solution to my problem. 我在Google上搜索了很长时间,但是找不到解决我问题的方法。

In fact I've got an entity, with two fields. 实际上,我有一个具有两个字段的实体。 One fields 'name' that is a string and a second field targetentity that is also a string containing a namespace to an entity. 一个字段“名称”是一个字符串,第二个字段目标实体也是一个包含实体名称空间的字符串。 The namespace can be choice with a select and can be different. 命名空间可以通过选择进行选择,并且可以不同。 So I wan't in my sonata admin bundle when I'm on my list action make a link in the table to redirect to the route list of the entity select. 因此,当我在列表操作中时,我就不在我的奏鸣曲管理捆绑中,在表中创建一个链接以重定向到所选实体的路由列表。

Someone know how to do this? 有人知道该怎么做吗?

I think you can use a form with type choice read this link it will help you 我认为您可以使用带有类型选择的表格阅读此链接,它将对您有所帮助

http://symfony.com/doc/current/reference/forms/types/choice.html http://symfony.com/doc/current/reference/forms/types/choice.html

You can override the listview as described here: http://blog.webdevilopers.net/override-list-view-twig-template-in-sonataadminbundle/ or here: Modifying list view in Sonata 您可以按以下说明覆盖列表视图: http : //blog.webdevilopers.net/override-list-view-twig-template-in-sonataadminbundle/或此处: 在Sonata中修改列表视图

In the list view you have the admin class available. 在列表视图中,您可以使用管理类。 What you can do is add a function in your admin that return the right url: 您可以做的是在您的管理员中添加一个返回正确网址的函数:

public function generateMyUrl($object){
    // add your logic here
    $url = $this->generateObjectUrl($name, $object, $parameters, $absolute);
    return $url;
}

In your inner_list_row template 在您的inner_list_row模板中

<a href="{{ admin.generateMyUrl(object) }}" target="_blank">
    your link description
</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM