Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug-fix] Fix default form problem with _token field #12378

Merged
merged 1 commit into from Feb 23, 2021

Conversation

Zales0123
Copy link
Member

Discussion

Q A
Branch? 1.9
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

After upgrade to Symfony 5, there is a problem with the default form for custom resources. Already rendered _token with form_widget(form) throws an exception when rendered again (previously it was just not rendered again).

Zrzut ekranu 2021-02-23 o 12 55 30

Probably it would be nice to have some test for a custom resource with default templates 馃拑 Write now it can be easily reproduced by removing vars->all->templates->form from one of the resources (e.g. AdminUser).

@Zales0123 Zales0123 added the Bug Confirmed bugs or bugfixes. label Feb 23, 2021
@Zales0123 Zales0123 requested a review from a team as a code owner February 23, 2021 12:05
@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Feb 23, 2021
@pamil pamil merged commit cb7d201 into Sylius:1.9 Feb 23, 2021
@pamil
Copy link
Contributor

pamil commented Feb 23, 2021

Thanks, Mateusz! 馃

@Zales0123 Zales0123 deleted the default-form-token-bug-fix branch February 23, 2021 12:32
@maximehuran
Copy link
Contributor

maximehuran commented Mar 10, 2021

Why do we have to keep the {{ form_row(form._token) }} when configuration.vars.templates.form is defined ?
I have an issue on one of our plugin because we customize the template form and I have the same error :

An exception has been thrown during the rendering of a template ("Field "_token" has already been rendered, save the result of previous render call to a variable and output that instead.").

I think the best way to manage it is to use :

{% if not form._token.isRendered %}
            {{ form_row(form._token) }}
        {% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin AdminBundle related issues and PRs. Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants