我试图动态地初始化一个表单.表单名称存储在$ obj-> getFormTypeName()中.
$formName = 'Acme\testBundle\Form\CustomType\\'.ucfirst($obj->getFormTypeName()).'Type';
$contactForms[$obj->getId()] = $this->createForm($formName::class);
Run Code Online (Sandbox Code Playgroud)
但我得到错误: Compile Error: Dynamic class names are not allowed in compile-time ::class fetch
有没有办法用symfony中的Scope Resolution Operator动态初始化表单?
谢谢阅读.