Skip to content

Commit 1c9586f

Browse files
Nyholmmpiot
authored andcommitted
Added form_help on horizontal design and removed special variable
1 parent 953c95a commit 1c9586f

7 files changed

+43
-9
lines changed

Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ col-sm-2
2323
{# Rows #}
2424

2525
{% block form_row -%}
26+
{%- set widget_attr = {} -%}
27+
{%- if help is not empty -%}
28+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
29+
{%- endif -%}
2630
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
2731
{{- form_label(form) -}}
2832
<div class="{{ block('form_group_class') }}">
29-
{{- form_widget(form) -}}
33+
{{- form_widget(form, widget_attr) -}}
34+
{{- form_help(form) -}}
3035
{{- form_errors(form) -}}
3136
</div>
3237
{##}</div>

Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@
8989
{# Rows #}
9090

9191
{% block form_row -%}
92+
{%- set widget_attr = {} -%}
93+
{%- if help is not empty -%}
94+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
95+
{%- endif -%}
9296
<div class="form-group{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
9397
{{- form_label(form) -}}
94-
{{- form_widget(form, { 'helpBlockDisplayed': true }) -}}
98+
{{- form_widget(form, widget_attr) -}}
9599
{{- form_help(form) -}}
96100
{{- form_errors(form) -}}
97101
</div>

Resources/views/Form/bootstrap_4_horizontal_layout.html.twig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,31 @@ col-sm-2
2424
{%- if expanded is defined and expanded -%}
2525
{{ block('fieldset_form_row') }}
2626
{%- else -%}
27+
{%- set widget_attr = {} -%}
28+
{%- if help is not empty -%}
29+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
30+
{%- endif -%}
2731
<div class="form-group row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}">
2832
{{- form_label(form) -}}
2933
<div class="{{ block('form_group_class') }}">
30-
{{- form_widget(form) -}}
34+
{{- form_widget(form, widget_attr) -}}
35+
{{- form_help(form) -}}
3136
</div>
3237
{##}</div>
3338
{%- endif -%}
3439
{%- endblock form_row %}
3540

3641
{% block fieldset_form_row -%}
42+
{%- set widget_attr = {} -%}
43+
{%- if help is not empty -%}
44+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
45+
{%- endif -%}
3746
<fieldset class="form-group">
3847
<div class="row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}">
3948
{{- form_label(form) -}}
4049
<div class="{{ block('form_group_class') }}">
41-
{{- form_widget(form) -}}
50+
{{- form_widget(form, widget_attr) -}}
51+
{{- form_help(form) -}}
4252
</div>
4353
</div>
4454
{##}</fieldset>

Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,13 @@
257257
{%- if compound is defined and compound -%}
258258
{%- set element = 'fieldset' -%}
259259
{%- endif -%}
260+
{%- set widget_attr = {} -%}
261+
{%- if help is not empty -%}
262+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
263+
{%- endif -%}
260264
<{{ element|default('div') }} class="form-group">
261265
{{- form_label(form) -}}
262-
{{- form_widget(form, { 'helpBlockDisplayed': true }) -}}
266+
{{- form_widget(form, widget_attr) -}}
263267
{{- form_help(form) -}}
264268
</{{ element|default('div') }}>
265269
{%- endblock form_row %}

Resources/views/Form/form_div_layout.html.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,14 @@
306306
{%- endblock repeated_row -%}
307307

308308
{%- block form_row -%}
309+
{%- set widget_attr = {} -%}
310+
{%- if help is not empty -%}
311+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
312+
{%- endif -%}
309313
<div>
310314
{{- form_label(form) -}}
311315
{{- form_errors(form) -}}
312-
{{- form_widget(form, { 'helpBlockDisplayed': true }) -}}
316+
{{- form_widget(form, widget_attr) -}}
313317
{{- form_help(form) -}}
314318
</div>
315319
{%- endblock form_row -%}
@@ -397,7 +401,6 @@
397401
id="{{ id }}" name="{{ full_name }}"
398402
{%- if disabled %} disabled="disabled"{% endif -%}
399403
{%- if required %} required="required"{% endif -%}
400-
{%- if helpBlockDisplayed is defined and helpBlockDisplayed is same as(true) and help is not empty %} aria-describedby="{{ id }}_help"{% endif -%}
401404
{{ block('attributes') }}
402405
{%- endblock widget_attributes -%}
403406

Resources/views/Form/form_table_layout.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{% use "form_div_layout.html.twig" %}
22

33
{%- block form_row -%}
4+
{%- set widget_attr = {} -%}
5+
{%- if help is not empty -%}
6+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
7+
{%- endif -%}
48
<tr>
59
<td>
610
{{- form_label(form) -}}
711
</td>
812
<td>
913
{{- form_errors(form) -}}
10-
{{- form_widget(form, { 'helpBlockDisplayed': true }) -}}
14+
{{- form_widget(form, widget_attr) -}}
1115
{{- form_help(form) -}}
1216
</td>
1317
</tr>

Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,14 @@
267267
{# Rows #}
268268

269269
{% block form_row -%}
270+
{%- set widget_attr = {} -%}
271+
{%- if help is not empty -%}
272+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
273+
{%- endif -%}
270274
<div class="row">
271275
<div class="large-12 columns{% if (not compound or force_error|default(false)) and not valid %} error{% endif %}">
272276
{{ form_label(form) }}
273-
{{- form_widget(form, { 'helpBlockDisplayed': true }) -}}
277+
{{- form_widget(form, widget_attr) -}}
274278
{{ form_help(form) }}
275279
{{ form_errors(form) }}
276280
</div>

0 commit comments

Comments
 (0)