如何编辑Symfony 5,EasyAdmin 4中的主菜单标签?

发布于 2025-01-26 08:45:24 字数 838 浏览 4 评论 0原文

我正在使用Symfony EasyAdmin 4 ,无法弄清楚如何更改主菜单的实体标签。他们默认为实体的名称。

这似乎可以使用 EasyAdmin 2.x 可以实现,因为旧文档显示。但是,那里没有提到的文件(translations.xx.yamlconfig/packages/easy_admin.yaml)仍在 easyadmin 4.x 4.x

那么,如何在EasyAdmin中编辑主菜单标签?

I am using Symfony EasyAdmin 4 and couldn't figure out how to change the main menu's entities' labels. They default to their entities' name.

This seems easily achievable with EasyAdmin 2.x, as the old docs show. But none of the files mentioned there (translations/messages.xx.yaml,config/packages/easy_admin.yaml) is still in use in EasyAdmin 4.x.

So, how to edit the Main Menu Labels in EasyAdmin?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极度宠爱 2025-02-02 08:45:24

我们不需要easyAdmin 4中的任何这些文件:

这可以通过简单地实现setEntityLabelinsingularsetEntityLabeLInplural 中的方法来实现。 configurecrud相关CRUD控制器内部的方法:

class YourCrudController extends AbstractCrudController
{     
    public function configureCrud(Crud $crud): Crud
         {
             return $crud
                 ->setEntityLabelInSingular('Your own label')
                 ->setEntityLabelInPlural('Your own labels')
                 ...
                 ;
          }
...
}

不要忘记使用EasyCorp \ Bundle \ EasyAdminBundle \ config \ config \ crud \ crud \ crud;


在此处: symfony:快速轨道

We don't need any of those files in EasyAdmin 4:

This can be achieved by simply implementing setEntityLabelInSingular and setEntityLabelInPlural methods inside the configureCrud method inside the concerned crud controller:

class YourCrudController extends AbstractCrudController
{     
    public function configureCrud(Crud $crud): Crud
         {
             return $crud
                 ->setEntityLabelInSingular('Your own label')
                 ->setEntityLabelInPlural('Your own labels')
                 ...
                 ;
          }
...
}

Don't forget the : use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;


More here: Symfony: The Fast Track

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文