Add block prefix to csrf token field#29862
Merged
fabpot merged 1 commit intosymfony:masterfrom Jan 16, 2019
Merged
Conversation
5a7c246 to
0f369c9
Compare
|
|
||
| $csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, array( | ||
| $csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, [ | ||
| 'block_prefix' => 'token', |
Member
|
This looks nice to me ... but I'd like to ask @HeahDude and @vudaltsov if they can imagine any problem for adding this option unconditionally and for "hardcoding" its value. Thanks! |
vudaltsov
approved these changes
Jan 15, 2019
HeahDude
approved these changes
Jan 15, 2019
Contributor
HeahDude
left a comment
There was a problem hiding this comment.
This is a really simple and nice addition, thank you very much!
fabpot
approved these changes
Jan 16, 2019
Member
|
Thank you @alexander-schranz. |
fabpot
added a commit
that referenced
this pull request
Jan 16, 2019
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
Merged
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently I use the following code snippet to overwrite the token rendering:
{%- 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:
{%- block token_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', { 'form': form.parent.vars.name })) }} {%- endblock token_widget -%}