链接到其他CRUD控制器的某些动作
在用easyAdmin 4.x
制成的CRUD控制器中,是否有任何解决方法可以将新操作链接到另一个具有OneTomany关系的CRUD控制器中的操作?
class FirstEntityCrudController extends AbstractCrudController
{
...
public function configureActions(Actions $actions): Actions
{
return $actions
->add(Crud::PAGE_INDEX, Action::new('add-second-entity','Add a second entity')
->linkToCrudAction(Action::NEW ???)
)
;
}
}
docs 我可以使用:
linkTocrudaction():执行当前CRUD控制器的某些方法;
但是,似乎没有任何迹象表明如何“执行某种 crud控制器的方法”。
笔记: 有一种偷偷摸摸的方法,但似乎不健康:
->linkToUrl('the url to the desired action')
使用:
- PHP 8.1
- Symfony 5.4
- EasyAdmin 4.x
Is there any workaround to link a new action, in a CRUD controller made with EasyAdmin 4.x
, to an action in another CRUD controller with which it has a OneToMany relation ?
class FirstEntityCrudController extends AbstractCrudController
{
...
public function configureActions(Actions $actions): Actions
{
return $actions
->add(Crud::PAGE_INDEX, Action::new('add-second-entity','Add a second entity')
->linkToCrudAction(Action::NEW ???)
)
;
}
}
The docs say that I can use:
linkToCrudAction(): to execute some method of the current CRUD controller;
But there seems to be no indication on how to "execute some method of a different CRUD controller".
Note:
There is a sneaky way around it but it doesn't seem healthy :
->linkToUrl('the url to the desired action')
Using:
- PHP 8.1
- Symfony 5.4
- EasyAdmin 4.x
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下 @ruban 的评论,然后AS easyadminbundle 的文档提及,我们可以使用
Adminurlgenerator
类为所需操作生成一个URL,如下所示Following @Ruban's comment, and as EasyAdminBundle's docs mention, we can generate a URL for the desired action using the
AdminUrlGenerator
class as follow:This worked for me.