-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add documentation to overwrite token widget block using esi #10867
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@alexander-schranz I appreciate your contribution a lot and it shows how well you know Symfony! However, I'm going to close it without merging it 😢 Let me explain why:
However, thanks to your contribution we've made some improvements:
So, even if your contribution didn't make it this time, it helped us a lot to improve things and that's why I thank you for it. Cheers! |
@javiereguiluz thx for the kind words and your work on improving the documentation! What about the feature request (symfony/symfony#29862) should I document the token prefix somewhere else or do you mean its enough that the block_prefix is documented in the form docs (#10835) or will the feature PR also be closed? |
I like your PR in Symfony code and I hope it gets merged. Then, we need to merge #10835 and then we can think if we can add some note somewhere about this csrf token block prefix (maybe in security/csrf.rst). Problem is that after #10835 I think we need to revamp the article about customizing form rendering. It's too complex and verbose and thanks to the latest improvements we can make it much better. |
This PR was squashed before being merged into the 4.3-dev branch (closes #29862). Discussion ---------- Add block prefix to csrf token field | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... | License | MIT | Doc PR | symfony/symfony-docs#10867 Currently I use the following code snippet to overwrite the token rendering: ```twig {%- block hidden_widget -%} {%- if form.vars.name == '_token' -%} {{ block('app__token_widget') }} {%- else -%} {{ block('hidden_widget', 'form_div_layout.html.twig') }} {%- endif -%} {%- endblock hidden_widget -%} {%- block app__token_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', { 'form': form.parent.vars.name })) }} {%- endblock app__token_widget -%} ``` With the change of https://symfony.com/blog/new-in-symfony-4-3-simpler-form-theming this workaround can now be removed and the following can be used: ```twig {%- block token_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', { 'form': form.parent.vars.name })) }} {%- endblock token_widget -%} ``` Commits ------- 02bd6893a5 Add block prefix to csrf token field
This PR was squashed before being merged into the 4.3-dev branch (closes #29862). Discussion ---------- Add block prefix to csrf token field | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... | License | MIT | Doc PR | symfony/symfony-docs#10867 Currently I use the following code snippet to overwrite the token rendering: ```twig {%- block hidden_widget -%} {%- if form.vars.name == '_token' -%} {{ block('app__token_widget') }} {%- else -%} {{ block('hidden_widget', 'form_div_layout.html.twig') }} {%- endif -%} {%- endblock hidden_widget -%} {%- block app__token_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', { 'form': form.parent.vars.name })) }} {%- endblock app__token_widget -%} ``` With the change of https://symfony.com/blog/new-in-symfony-4-3-simpler-form-theming this workaround can now be removed and the following can be used: ```twig {%- block token_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', { 'form': form.parent.vars.name })) }} {%- endblock token_widget -%} ``` Commits ------- 02bd689 Add block prefix to csrf token field
@javiereguiluz thank you! I at least created an issue for this: #10884 |
See symfony/symfony#29862