8000 [Form][TwigBridge] Don't render _method in form_rest() for a child form by fmarchalemisys · Pull Request #23649 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form][TwigBridge] Don't render _method in form_rest() for a child form #23649

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 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
{% endif %}
{%- endfor %}

{% if not form.methodRendered %}
{% if not form.methodRendered and form.parent is null %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might break, if a field is named "parent". As discussed in #19492, I think we should be able to hardcode:

{% if not form.methodRendered and not form.hasParent %}

to know if a form view is a root.

Copy link
Contributor
@ogizanagi ogizanagi Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitated suggesting to add a FormView::needsMethodToBeRendered() method instead, which will do this check inside, as rendering the method input does only makes sense for a root form anyway and would avoid this issue.

Besides that, we already use form.parent in multiple places, so I don't think the related issue should be considered here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, your solution sounds good though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll suggest it in another PR then.

{%- do form.setMethodRendered() -%}
{% set method = method|upper %}
{%- if method in ["GET", "POST"] -%}
Expand Down
0