EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Tabs with lables implementing `TranslatableInterface` will lead to a crash

Open dragosprotung opened this issue 10 months ago • 0 comments

Describe the bug Setting the tab label to a TranslatableInterface will lead to a crash

To Reproduce

// Add a tab
FormField::addTab(new \Symfony\Component\Translation\TranslatableMessage('some.translation.key'));

Additional context

TypeError:
strip_tags(): Argument #1 ($string) must be of type string, SecondIT\Infinity\Audit\Translation\Model\Asset\DeviceType given

  at vendor/easycorp/easyadmin-bundle/src/Factory/FormLayoutFactory.php:185
  at strip_tags(object(DeviceType))
     (vendor/easycorp/easyadmin-bundle/src/Factory/FormLayoutFactory.php:185)
  at EasyCorp\Bundle\EasyAdminBundle\Factory\FormLayoutFactory->linearizeLayoutConfiguration(object(FieldCollection))
     (vendor/easycorp/easyadmin-bundle/src/Factory/FormLayoutFactory.php:43)
  at EasyCorp\Bundle\EasyAdminBundle\Factory\FormLayoutFactory->createLayout(object(FieldCollection), 'detail')
     (vendor/easycorp/easyadmin-bundle/src/Factory/FieldFactory.php:119)
  at EasyCorp\Bundle\EasyAdminBundle\Factory\FieldFactory->processFields(object(EntityDto), object(FieldCollection))
     (vendor/easycorp/easyadmin-bundle/src/Factory/EntityFactory.php:43)
  at EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory->processFields(object(EntityDto), object(FieldCollection))
     (vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:183)
  at EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController->detail(object(AdminContext))
     (vendor/symfony/http-kernel/HttpKernel.php:183)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:182)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:29)
  at require_once('/app/vendor/autoload_runtime.php')
     (public/index.php:9)                

Not sure what the correct fix for this would be. Inecting the Translator into FormLayoutFactory would be a direction, but how to get the current locale ?

dragosprotung avatar Mar 07 '25 08:03 dragosprotung