Closed
Description
Symfony version(s) affected
5.4.2
Description
The problem appears when running symfony as a daemon with swoole web server. The option block_prefix is settable once. In other requests it is impossible to set this option to another value. Twig renders form as the block_prefix is not changed, although each time new form instance is created.
How to reproduce
Example is from EasyCorp\Bundle\EasyAdminBundle\Factory:
$this->symfonyFormFactory->createNamedBuilder($entityDto->getName(), CrudFormType::class, $entityDto->getInstance(), $formOptions->all());
If set first parameter to something random value the problem disappears.
And in controller set option like this:
if ($someCondition) {
$field->getAsDto()->setFormTypeOption('block_prefix', 'some_prefix');
}
Possible Solution
I have decorated twig.form.engine (Symfony\Bridge\Twig\Form\TwigRendererEngine) with function, which is called on kernel.request event:
public function init()
{
$this->resources = [];
}
It works, but I am not sure it is the right solution.
Additional Context
No response