Skip to content

[TwigBridge][Form] Multiple rendering of form collection prototypes by form_div_layout.html.twig #29489

Closed
@kagje

Description

@kagje

Symfony version(s) affected: 4.2.0

Description
When the form_div_layout.html.twig file is used for form theming, a collection widget will try to render its 'prototype' property, regardless of whether it has already been rendered elsewhere (ie. by a custom extending theme). This causes an E_USER_DEPRECATED error to be triggered by the FormRenderer.

How to reproduce
Create a form theme file similar to this:

{% use 'form_div_layout.html.twig' %}

{% block _mycollection_row %}
<div class="my-collection-container" data-prototype="{{ form_row(form.vars.prototype)|e('html_attr') }}">
    {{ form_widget(form) }}
</div>
{% endblock %}

Applying the theme should trigger the aforementioned deprecation error.

Possible Solution
Fixable by simply not rendering the prototype if it's already been rendered: 7011706

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