Skip to content

Commit 8928c5d

Browse files
bug #26326 [Form][WCAG] Added role="presentation" on tables & removed bootstrap4 table (Nyholm)
This PR was squashed before being merged into the 3.4 branch (closes #26326). Discussion ---------- [Form][WCAG] Added role="presentation" on tables & removed bootstrap4 table | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | According to my friend and WCAG2 expect [Sandra](https://twitter.com/sandrability): > Tables works best for table data, it should not be used for doing layouts. If you really really want to use the label add `role="presentation"`. This will make screen readers to ignore the table structure which will make it easier to navigate. It will also prevent screen readers to read "row 1, column 1". > But we should consider not using a table here. Commits ------- 635220a [Form][WCAG] Added role=\"presentation\" on tables & removed bootstrap4 table
2 parents 3381cdf + 5469022 commit 8928c5d

File tree

3 files changed

+43
-27
lines changed

3 files changed

+43
-27
lines changed

Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,48 @@
5858
{%- else -%}
5959
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
6060
<div {{ block('widget_container_attributes') }}>
61-
<div class="table-responsive">
62-
<table class="table {{ table_class|default('table-bordered table-condensed table-striped') }}">
63-
<thead>
64-
<tr>
65-
{%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}
66-
{%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%}
67-
{%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%}
68-
{%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%}
69-
{%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%}
70-
{%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%}
71-
{%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%}
72-
</tr>
73-
</thead>
74-
<tbody>
75-
<tr>
76-
{%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%}
77-
{%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%}
78-
{%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%}
79-
{%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%}
80-
{%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%}
81-
{%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%}
82-
{%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%}
83-
</tr>
84-
</tbody>
85-
</table>
61+
{%- if with_years -%}
62+
<div class="col-auto">
63+
{{ form_label(form.years) }}
64+
{{ form_widget(form.years) }}
8665
</div>
66+
{%- endif -%}
67+
{%- if with_months -%}
68+
<div class="col-auto">
69+
{{ form_label(form.months) }}
70+
{{ form_widget(form.months) }}
71+
</div>
72+
{%- endif -%}
73+
{%- if with_weeks -%}
74+
<div class="col-auto">
75+
{{ form_label(form.weeks) }}
76+
{{ form_widget(form.weeks) }}
77+
</div>
78+
{%- endif -%}
79+
{%- if with_days -%}
80+
<div class="col-auto">
81+
{{ form_label(form.days) }}
82+
{{ form_widget(form.days) }}
83+
</div>
84+
{%- endif -%}
85+
{%- if with_hours -%}
86+
<div class="col-auto">
87+
{{ form_label(form.hours) }}
88+
{{ form_widget(form.hours) }}
89+
</div>
90+
{%- endif -%}
91+
{%- if with_minutes -%}
92+
<div class="col-auto">
93+
{{ form_label(form.minutes) }}
94+
{{ form_widget(form.minutes) }}
95+
</div>
96+
{%- endif -%}
97+
{%- if with_seconds -%}
98+
<div class="col-auto">
99+
{{ form_label(form.seconds) }}
100+
{{ form_widget(form.seconds) }}
101+
</div>
102+
{%- endif -%}
87103
{%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
88104
</div>
89105
{%- endif -%}

Resources/views/Form/bootstrap_base_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<div {{ block('widget_container_attributes') }}>
108108
{{- form_errors(form) -}}
109109
<div class="table-responsive">
110-
<table class="table {{ table_class|default('table-bordered table-condensed table-striped') }}">
110+
<table class="table {{ table_class|default('table-bordered table-condensed table-striped') }}" role="presentation">
111111
<thead>
112112
<tr>
113113
{%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}

Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
{%- else -%}
137137
<div {{ block('widget_container_attributes') }}>
138138
{{- form_errors(form) -}}
139-
<table class="{{ table_class|default('') }}">
139+
<table class="{{ table_class|default('') }}" role="presentation">
140140
<thead>
141141
<tr>
142142
{%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}

0 commit comments

Comments
 (0)