Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
pamil merged 1 commit into
Sylius:1.9from
Zales0123:default-form-token-bug-fix
Feb 23, 2021
Merged

[Bug-fix] Fix default form problem with _token field#12378
pamil merged 1 commit into
Sylius:1.9from
Zales0123:default-form-token-bug-fix

Conversation

@Zales0123
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown

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.

5 participants