Skip to content

Commit b3e9a65

Browse files
committed
[TwigBridge] Add row_attr to all form themes
1 parent 4a866d0 commit b3e9a65

7 files changed

+21
-21
lines changed

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

+4-4
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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group' ~ ((not compound or force_error|default(false)) and not valid ? ' has-error')})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group' ~ (not valid ? ' has-error')})} %}{{ 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

+4-4
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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group' ~ ((not compound or force_error|default(false)) and not valid ? ' has-error')})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group' ~ (not valid ? ' has-error')})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group' ~ (not valid ? ' has-error')})} %}{{ 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

+5-5
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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group row' ~ ((not compound or force_error|default(false)) and not valid ? ' is-invalid')})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group row'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group row'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group row'})} %}{{ 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

+1-1
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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group'})} %}{{ 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

+1-1
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.class is defined ? row_attr : row_attr|default({})|merge({class: 'form-group'})} %}{{ block('attributes') }}{% endwith %}>
191191
{{- form_widget(form) -}}
192192
</div>
193193
{%- endblock button_row %}

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

+3-3
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|default({})} %}{{ 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|default({})} %}{{ 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.style is defined ? row_attr : row_attr|default({})|merge({style: 'display: none'})} %}{{ 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

+3-3
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.class is defined ? row_attr : row_attr|default({})|merge({class: 'row'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'row'})} %}{{ 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.class is defined ? row_attr : row_attr|default({})|merge({class: 'row'})} %}{{ block('attributes') }}{% endwith %}>
321321
<div class="large-12 columns{% if not valid %} error{% endif %}">
322322
{{ form_widget(form) }}
323323
{{ form_errors(form) }}

0 commit comments

Comments
 (0)