Description
Symfony version(s) affected
7.1.3, 7.2.4
Description
Provided that you have nested collections in a form,
and if the parent FormType
have changed the getParent
method,
all childs are using the parent block_prefix
even though it is not applicable.
I have noted 7.1.3
and 7.2.4
, because I had the issue on a 7.1.3
, and reproduced on 7.2.4
, but it may appear in more versions.
How to reproduce
I created a reproducer project
https://github.com/yann-eugone/symfony-nested-collection-block-prefixes
It is based on an example taken from the documentation
https://symfony.com/doc/current/form/form_themes.html#fragment-naming-for-collections
There is a TaskManagerType
that has a CollectionType<TaskListType>
in a taskLists
field.
There is a TaskListType
that has a CollectionType<TaskType>
in a tasks
field.
And finally a TaskType
that has a StringType
in a name
field.
The TaskListType
has overriden the getParent
method, and set it to EmbeddedType
(an other, empty form type created for the project)
The problem occurs when you try to customize the rendering of EmbeddedType
.
The block embedded_row
seems to be applied to all children, even though the embedded
prefix is not part of the block_prefixes
list.
Possible Solution
No response
Additional Context
No response