8000 Add documentation to overwrite token widget block using esi by alexander-schranz · Pull Request #10867 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 5 commits into from

Conversation

alexander-schranz
Copy link
Contributor

@javiereguiluz
Copy link
Member

@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:

  • This doc repeats some concepts that are explained in other articles (such as creating custom form blocks and dealing with ESI fragments). We're working to reduce repetition in Symfony Docs to make them easier to maintain.
  • This doc is too detailed and low level ... it looks more appropriate for a tutorial outside of Symfony Docs.

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!

@alexander-schranz alexander-schranz deleted the patch-1 branch January 14, 2019 18:54
@alexander-schranz
Copy link
Contributor Author
alexander-schranz commented Jan 14, 2019

@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?

@javiereguiluz
Copy link
Member

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.

symfony-splitter pushed a commit to symfony/form 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
-------

02bd6893a5 Add block prefix to csrf token field
fabpot added a commit to symfony/symfony 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
@alexander-schranz
Copy link
Contributor Author

@javiereguiluz thank you! I at least created an issue for this: #10884

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0