Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Add block prefix to csrf token field#29862
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
5a7c246 to0f369c9Compare| $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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
token ->csrf_token ?
javiereguiluz commentedJan 15, 2019
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! |
HeahDude left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is a really simple and nice addition, thank you very much!
fabpot commentedJan 16, 2019
Thank you@alexander-schranz. |
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#10867Currently 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 ofhttps://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
Uh oh!
There was an error while loading.Please reload this page.
Currently I use the following code snippet to overwrite the token rendering:
{%-blockhidden_widget -%} {%-ifform.vars.name=='_token' -%} {{block('app__token_widget') }} {%-else -%} {{block('hidden_widget','form_div_layout.html.twig') }} {%-endif -%}{%-endblockhidden_widget -%}{%-blockapp__token_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', {'form':form.parent.vars.name })) }}{%-endblockapp__token_widget -%}With the change ofhttps://symfony.com/blog/new-in-symfony-4-3-simpler-form-theming this workaround can now be removed and the following can be used:
{%-blocktoken_widget %} {{ render_esi(controller('SuluFormBundle:FormWebsite:token', {'form':form.parent.vars.name })) }}{%-endblocktoken_widget -%}