-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBridge] Set Form ID on form element, prevent duplicate form element attributes #48013
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
base: 7.3
Are you sure you want to change the base?
Conversation
src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
Outdated
Show resolved
Hide resolved
I just updated the PR with the following changes:
|
Looks like a rebase is needed. Still up to do it? |
28f61d7
to
8dd761e
Compare
@nicolas-grekas PR has been rebase, however unit tests are failing with high and low deps and I don't know why! |
looks like you need to update the |
8dd761e
to
3f3d763
Compare
I pushed the fix to the composer.json. |
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.
Since this issue has been there for a long time already, maybe this should target 6.4 to prevent side effects in the LTS.
@nicolas-grekas description update 👍 @HeahDude I agree to target |
Would be better I agree. Can you update the target of this PR and rebase on 6.4 please? |
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.
you will need to update the version constraints similarly to what Nicolas did in 3f3d763#diff-33dca46fccec7efe765aa6cf249fddcdde0d15fa2d01adc052a5e1da01b423c5
8d6067d
to
abb301b
Compare
@@ -1,7 +1,7 @@ | ||
{% use "bootstrap_3_layout.html.twig" %} | ||
|
||
{% block form_start -%} | ||
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %} | ||
{% set row_attr = row_attr|merge({class: (row_attr.class|default('') ~ ' form-horizontal')|trim}) %} |
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.
If we have to make this change here, it seems to me that we need to adapt for custom form types that do not provide the row_attr
variable (and that we need to fall back to attr
then).
42ed263
to
16d3589
Compare
As explained in #42075, when a form is rendered, its ID is displayed in the child div of the
<form>
element.This prevents to use the form_attr option on
FormType
.Moreover, attributes defined on
<form>
element are duplicated in the childdiv
For example, the following form
has the following HTML rendering
This PR provides the following fixes
form_id
is available in the view. It is the concatenation ofform_
and theID
of the form.<form>
element uses therow_attr
option instead ofattr
to display attributes. Therow_attr
option was never used on the root form and this avoids duplicating attributes.form_attr
option now only accepts a boolean value.form
attribute with theform_id
as value.form
attribute with theform_id
as value.