8000 [TwigBridge] Add row_attr to all form themes · symfony/symfony@310d6bb · GitHub
[go: up one dir, main page]

Skip to content

Commit 310d6bb

Browse files
committed
[TwigBridge] Add row_attr to all form themes
1 parent 479d8ee commit 310d6bb

9 files changed

+34
-34
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ col-sm-2
2727
{%- if help is not empty -%}
2828
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
2929
{%- endif -%}
30-
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
30+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ ((not compound or force_error|default(false)) and not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
3131
{{- form_label(form) -}}
3232
<div class="{{ block('form_group_class') }}">
3333
{{- form_widget(form, widget_attr) -}}
@@ -38,7 +38,7 @@ col-sm-2
3838
{%- endblock form_row %}
3939

4040
{% block submit_row -%}
41-
<div class="form-group">{#--#}
41+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
4242
<div class="{{ block('form_label_class') }}"></div>{#--#}
4343
<div class="{{ block('form_group_class') }}">
4444
{{- form_widget(form) -}}
@@ -47,7 +47,7 @@ col-sm-2
4747
{%- endblock submit_row %}
4848

4949
{% block reset_row -%}
50-
<div class="form-group">{#--#}
50+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
5151
<div class="{{ block('form_label_class') }}"></div>{#--#}
5252
<div class="{{ block('form_group_class') }}">
5353
{{- form_widget(form) -}}
@@ -60,7 +60,7 @@ col-sm-10
6060
{%- endblock form_group_class %}
6161

6262
{% block checkbox_row -%}
63-
<div class="form-group{% if not valid %} has-error{% endif %}">{#--#}
63+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
6464
<div class="{{ block('form_label_class') }}"></div>{#--#}
6565
<div class="{{ block('form_group_class') }}">
6666
{{- form_widget(form) -}}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
{%- if help is not empty -%}
112112
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
113113
{%- endif -%}
114-
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
114+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ ((not compound or force_error|default(false)) and not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
115115
{{- form_label(form) }} {# -#}
116116
{{ form_widget(form, widget_attr) }} {# -#}
117117
{{- form_help(form) -}}
@@ -120,7 +120,7 @@
120120
{%- endblock form_row %}
121121

122122
{% block button_row -%}
123-
<div class="form-group">
123+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
124124
{{- form_widget(form) -}}
125125
</div>
126126
{%- endblock button_row %}
@@ -146,14 +146,14 @@
146146
{%- endblock datetime_row %}
147147

148148
{% block checkbox_row -%}
149-
<div class="form-group{% if not valid %} has-error{% endif %}">
149+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
150150
{{- form_widget(form) -}}
151151
{{- form_errors(form) -}}
152152
</div>
153153
{%- endblock checkbox_row %}
154154

155155
{% block radio_row -%}
156-
<div class="form-group{% if not valid %} has-error{% endif %}">
156+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
157157
{{- form_widget(form) -}}
158158
{{- form_errors(form) -}}
159159
</div>

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_horizontal_layout.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ col-sm-2
2828
{%- if help is not empty -%}
2929
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
3030
{%- endif -%}
31-
<div class="form-group row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}">
31+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row' ~ ((not compound or force_error|default(false)) and not valid ? ' is-invalid'))|trim})} %}{{ block('attributes') }}{% endwith %}>
3232
{{- form_label(form) -}}
3333
<div class="{{ block('form_group_class') }}">
3434
{{- form_widget(form, widget_attr) -}}
@@ -43,7 +43,7 @@ col-sm-2
4343
{%- if help is not empty -%}
4444
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
4545
{%- endif -%}
46-
<fieldset class="form-group">
46+
<fieldset{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
4747
<div class="row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}">
4848
{{- form_label(form) -}}
4949
<div class="{{ block('form_group_class') }}">
@@ -55,7 +55,7 @@ col-sm-2
5555
{%- endblock fieldset_form_row %}
5656

5757
{% block submit_row -%}
58-
<div class="form-group row">{#--#}
58+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
5959
<div class="{{ block('form_label_class') }}"></div>{#--#}
6060
<div class="{{ block('form_group_class') }}">
6161
{{- form_widget(form) -}}
@@ -64,7 +64,7 @@ col-sm-2
6464
{%- endblock submit_row %}
6565

6666
{% block reset_row -%}
67-
<div class="form-group row">{#--#}
67+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
6868
<div class="{{ block('form_label_class') }}"></div>{#--#}
6969
<div class="{{ block('form_group_class') }}">
7070
{{- form_widget(form) -}}
@@ -77,7 +77,7 @@ col-sm-10
7777
{%- endblock form_group_class %}
7878

7979
{% block checkbox_row -%}
80-
<div class="form-group row">{#--#}
80+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#}
8181
<div class="{{ block('form_label_class') }}"></div>{#--#}
8282
<div class="{{ block('form_group_class') }}">
8383
{{- form_widget(form) -}}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
{%- if help is not empty -%}
283283
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
284284
{%- endif -%}
285-
<{{ element|default('div') }} class="form-group">
285+
<{{ element|default('div') }}{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
286286
{{- form_label(form) -}}
287287
{{- form_widget(form, widget_attr) -}}
288288
{{- form_help(form) -}}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
{# Rows #}
188188

189189
{% block button_row -%}
190-
<div class="form-group">
190+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group')|trim})} %}{{ block('attributes') }}{% endwith %}>
191191
{{- form_widget(form) -}}
192192
</div>
193193
{%- endblock button_row %}

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
{%- if help is not empty -%}
326326
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
327327
{%- endif -%}
328-
<div {% with {attr: row_attr|default({})} %}{{ block('attributes') }}{% endwith %}>
328+
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
329329
{{- form_label(form) -}}
330330
{{- form_errors(form) -}}
331331
{{- form_widget(form, widget_attr) -}}
@@ -334,7 +334,7 @@
334334
{%- endblock form_row -%}
335335

336336
{%- block button_row -%}
337-
<div {% with {attr: row_attr|default({})} %}{{ block('attributes') }}{% endwith %}>
337+
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
338338
{{- form_widget(form) -}}
339339
</div>
340340
{%- endblock button_row -%}

src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{%- if help is not empty -%}
66
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
77
{%- endif -%}
8-
<tr>
8+
<tr{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
99
<td>
1010
{{- form_label(form) -}}
1111
</td>
@@ -18,7 +18,7 @@
1818
{%- endblock form_row -%}
1919

2020
{%- block button_row -%}
21-
<tr>
21+
<tr{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
2222
<td></td>
2323
<td>
2424
{{- form_widget(form) -}}
@@ -27,7 +27,7 @@
2727
{%- endblock button_row -%}
2828

2929
{%- block hidden_row -%}
30-
<tr style="display: none">
30+
<tr{% with {attr: row_attr|merge({style: ('display: none; ' ~ row_attr.style|default(''))|trim})} %}{{ block('attributes') }}{% endwith %}>
3131
<td colspan="2">
3232
{{- form_widget(form) -}}
3333
</td>

src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
{%- if help is not empty -%}
278278
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
279279
{%- endif -%}
280-
<div class="row">
280+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>
281281
<div class="large-12 columns{% if (not compound or force_error|default(false)) and not valid %} error{% endif %}">
282282
{{- form_label(form) -}}
283283
{{- form_widget(form, widget_attr) -}}
@@ -308,7 +308,7 @@
308308
{%- endblock datetime_row %}
309309

310310
{% block checkbox_row -%}
311-
<div class="row">
311+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>
312312
<div class="large-12 columns{% if not valid %} error{% endif %}">
313313
{{ form_widget(form) }}
314314
{{ form_errors(form) }}
@@ -317,7 +317,7 @@
317317
{%- endblock checkbox_row %}
318318

319319
{% block radio_row -%}
320-
<div class="row">
320+
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>
321321
<div class="large-12 columns{% if not valid %} error{% endif %}">
322322
{{ form_widget(form) }}
323323
{{ form_errors(form) }}

src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testRepeatedRow()
7979
/following-sibling::td
8080
[./input[@id="name_second"]]
8181
]
82-
/following-sibling::tr[@style="display: none"]
82+
/following-sibling::tr[@style="display: none;"]
8383
[./td[@colspan="2"]/input
8484
[@type="hidden"]
8585
[@id="name__token"]
@@ -116,7 +116,7 @@ public function testRepeatedRowWithErrors()
116116
/following-sibling::td
117117
[./input[@id="name_second"]]
118118
]
119-
/following-sibling::tr[@style="display: none"]
119+
/following-sibling::tr[@style="display: none;"]
120120
[./td[@colspan="2"]/input
121121
[@type="hidden"]
122122
[@id="name__token"]
@@ -183,7 +183,7 @@ public function testRest()
183183
[count(../tr)=3]
184184
[count(..//label)=2]
185185
[count(..//input)=3]
186-
/following-sibling::tr[@style="display: none"]
186+
/following-sibling::tr[@style="display: none;"]
187187
[./td[@colspan="2"]/input
188188
[@type="hidden"]
189189
[@id="name__token"]
@@ -203,7 +203,7 @@ public function testCollection()
203203
[
204204
./tr[./td/input[@type="text"][@value="a"]]
205205
/following-sibling::tr[./td/input[@type="text"][@value="b"]]
206-
/following-sibling::tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]]
206+
/following-sibling::tr[@style="display: none;"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]]
207207
]
208208
[count(./tr[./td/input])=3]
209209
'
@@ -218,7 +218,7 @@ public function testEmptyCollection()
218218

219219
$this->assertWidgetMatchesXpath($form->createView(), [],
220220
'/table
221-
[./tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]]]
221+
[./tr[@style="display: none;"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]]]
222222
[count(./tr[./td/input])=1]
223223
'
224224
);
@@ -259,7 +259,7 @@ public function testForm()
259259
/following-sibling::td
260260
[./input[@id="name_lastName"]]
261261
]
262-
/following-sibling::tr[@style="display: none"]
262+
/following-sibling::tr[@style="display: none;"]
263263
[./td[@colspan="2"]/input
264264
[@type="hidden"]
265265
[@id="name__token"]
@@ -301,7 +301,7 @@ public function testFormWidget()
301301
/following-sibling::td
302302
[./input[@id="name_lastName"]]
303303
]
304-
/following-sibling::tr[@style="display: none"]
304+
/following-sibling::tr[@style="display: none;"]
305305
[./td[@colspan="2"]/input
306306
[@type="hidden"]
307307
[@id="name__token"]
@@ -352,7 +352,7 @@ public function testCsrf()
352352
$this->assertWidgetMatchesXpath($form->createView(), [],
353353
'/table
354354
[
355-
./tr[@style="display: none"]
355+
./tr[@style="display: none;"]
356356
[./td[@colspan="2"]/input
357357
[@type="hidden"]
358358
[@id="name__token"]
@@ -386,7 +386,7 @@ public function testRepeated()
386386
/following-sibling::td
387387
[./input[@type="text"][@id="name_second"]]
388388
]
389-
/following-sibling::tr[@style="display: none"]
389+
/following-sibling::tr[@style="display: none;"]
390390
[./td[@colspan="2"]/input
391391
[@type="hidden"]
392392
[@id="name__token"]
@@ -422,7 +422,7 @@ public function testRepeatedWithCustomOptions()
422422
/following-sibling::td
423423
[./input[@type="password"][@id="name_second"][@required="required"]]
424424
]
425-
/following-sibling::tr[@style="display: none"]
425+
/following-sibling::tr[@style="display: none;"]
426426
[./td[@colspan="2"]/input
427427
[@type="hidden"]
428428
[@id="name__token"]
@@ -482,7 +482,7 @@ public function testFormEndWithRest()
482482
/following-sibling::td
483483
[./input[@id="name_field2"]]
484484
]
485-
/following-sibling::tr[@style="display: none"]
485+
/following-sibling::tr[@style="display: none;"]
486486
[./td[@colspan="2"]/input
487487
[@type="hidden"]
488488
[@id="name__token"]

0 commit comments

Comments
 (0)
0