Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Wrong block prefix used in nested collections #59962

Copy link
Copy link
Open
@yann-eugone

Description

@yann-eugone
Issue body actions

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.

Image

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.