Skip to content

Commit a5ef369

Browse files
committed
Added comments to blocks.
1 parent 735bef8 commit a5ef369

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/Resources/views/Form/accessible-forms.html.twig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{# Extends vendor/symfony/twig-bridge/Resources/views/Form/form_div_layout.html.twig #}
22
{% use 'form_div_layout.html.twig' %}
33

4+
{# Custom block to list errors #}
45
{%- block form_error_summary -%}
56
{% if form is not valid %}
67
<div id="site-aria-alert" role="alert">
@@ -20,7 +21,7 @@
2021
{% endif %}
2122
{%- endblock form_error_summary -%}
2223

23-
{# Appears as error above each field #}
24+
{# Custom markup for field errors. Appears as error above each field #}
2425
{%- block form_errors -%}
2526
{%- if errors|length > 0 -%}
2627
{% for error in errors %}
@@ -29,11 +30,13 @@
2930
{%- endif -%}
3031
{%- endblock form_errors -%}
3132

33+
{# Add class to form start #}
3234
{%- block form_start -%}
3335
{% set attr = attr|merge({'class': 'tbxforms'}) %}
3436
{{- parent() -}}
3537
{%- endblock form_start -%}
3638

39+
{# Add class to form rows #}
3740
{%- block form_row -%}
3841
{% set row_attr = row_attr|merge({'class': 'tbxforms-form-group'}) %}
3942
{%- if errors|length > 0 -%}
@@ -43,7 +46,7 @@
4346
{{- parent() -}}
4447
{%- endblock form_row -%}
4548

46-
{# Field rows become fieldsets on checkbox and radio buttons, so make the label the legend #}
49+
{# Custom markup for labels. Compound groups become fieldsets, so make the label the legend for those #}
4750
{%- block form_label -%}
4851
{% if label is not same as(false) -%}
4952
{%- if compound -%}
@@ -62,6 +65,7 @@
6265
{%- endif -%}
6366
{%- endblock form_label -%}
6467

68+
{# Labels for checkboxes buttons in choice blocks #}
6569
{% block checkbox_label %}
6670
{% if label is not same as(false) -%}
6771
{% if not compound -%}
@@ -75,6 +79,7 @@
7579
{%- endif -%}
7680
{% endblock %}
7781

82+
{# Labels for radio buttons in choice blocks #}
7883
{% block radio_label %}
7984
{% if label is not same as(false) -%}
8085
{% if not compound -%}
@@ -88,6 +93,7 @@
8893
{%- endif -%}
8994
{% endblock %}
9095

96+
{# Custom markup for field hints #}
9197
{% block form_help -%}
9298
{%- if help -%}
9399
<div id="id_{{ id }}_hint" class="rnib-form-hint">
@@ -96,12 +102,11 @@
96102
{%- endif -%}
97103
{%- endblock form_help %}
98104

99-
{# Adjust order of elements in form row #}
105+
{# Adjust order of elements in form row, add fieldset for compound groups #}
100106
{%- block form_row_render -%}
101107
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
102108
{% if compound %}
103109
<fieldset class="tbxforms-fieldset">
104-
105110
{% endif %}
106111
{{- form_label(form) -}}
107112
{{- form_help(form) -}}
@@ -113,6 +118,7 @@
113118
</div>
114119
{%- endblock form_row_render -%}
115120

121+
{# This is for single non-choice checkboxes (eg. Agree to Terms) #}
116122
{% block checkbox_row %}
117123
<div class="tbxforms-form-group">
118124
<div class="tbxforms-checkboxes">
@@ -138,10 +144,12 @@
138144
</div>
139145
{%- endblock choice_widget_expanded -%}
140146

147+
{# Add class to checkboxes #}
141148
{%- block checkbox_widget -%}
142149
<input type="checkbox" class="tbxforms-checkboxes__input" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
143150
{%- endblock checkbox_widget -%}
144151

152+
{# Add class to radio buttons #}
145153
{%- block radio_widget -%}
146154
<input type="radio" class="govuk-radios__input" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
147155
{%- endblock radio_widget -%}
@@ -155,6 +163,7 @@
155163
{{- parent() -}}
156164
{%- endblock form_widget_simple -%}
157165

166+
{# Add class to select boxes #}
158167
{%- block choice_widget_collapsed -%}
159168
{% set attr = attr|merge({'class': 'tbxforms-select'}) %}
160169
{{- parent() -}}

0 commit comments

Comments
 (0)