|
1 | 1 | {# Extends vendor/symfony/twig-bridge/Resources/views/Form/form_div_layout.html.twig #} |
2 | 2 | {% use 'form_div_layout.html.twig' %} |
3 | 3 |
|
| 4 | +{# Custom block to list errors #} |
4 | 5 | {%- block form_error_summary -%} |
5 | 6 | {% if form is not valid %} |
6 | 7 | <div id="site-aria-alert" role="alert"> |
|
20 | 21 | {% endif %} |
21 | 22 | {%- endblock form_error_summary -%} |
22 | 23 |
|
23 | | -{# Appears as error above each field #} |
| 24 | +{# Custom markup for field errors. Appears as error above each field #} |
24 | 25 | {%- block form_errors -%} |
25 | 26 | {%- if errors|length > 0 -%} |
26 | 27 | {% for error in errors %} |
|
29 | 30 | {%- endif -%} |
30 | 31 | {%- endblock form_errors -%} |
31 | 32 |
|
| 33 | +{# Add class to form start #} |
32 | 34 | {%- block form_start -%} |
33 | 35 | {% set attr = attr|merge({'class': 'tbxforms'}) %} |
34 | 36 | {{- parent() -}} |
35 | 37 | {%- endblock form_start -%} |
36 | 38 |
|
| 39 | +{# Add class to form rows #} |
37 | 40 | {%- block form_row -%} |
38 | 41 | {% set row_attr = row_attr|merge({'class': 'tbxforms-form-group'}) %} |
39 | 42 | {%- if errors|length > 0 -%} |
|
43 | 46 | {{- parent() -}} |
44 | 47 | {%- endblock form_row -%} |
45 | 48 |
|
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 #} |
47 | 50 | {%- block form_label -%} |
48 | 51 | {% if label is not same as(false) -%} |
49 | 52 | {%- if compound -%} |
|
62 | 65 | {%- endif -%} |
63 | 66 | {%- endblock form_label -%} |
64 | 67 |
|
| 68 | +{# Labels for checkboxes buttons in choice blocks #} |
65 | 69 | {% block checkbox_label %} |
66 | 70 | {% if label is not same as(false) -%} |
67 | 71 | {% if not compound -%} |
|
75 | 79 | {%- endif -%} |
76 | 80 | {% endblock %} |
77 | 81 |
|
| 82 | +{# Labels for radio buttons in choice blocks #} |
78 | 83 | {% block radio_label %} |
79 | 84 | {% if label is not same as(false) -%} |
80 | 85 | {% if not compound -%} |
|
88 | 93 | {%- endif -%} |
89 | 94 | {% endblock %} |
90 | 95 |
|
| 96 | +{# Custom markup for field hints #} |
91 | 97 | {% block form_help -%} |
92 | 98 | {%- if help -%} |
93 | 99 | <div id="id_{{ id }}_hint" class="rnib-form-hint"> |
|
96 | 102 | {%- endif -%} |
97 | 103 | {%- endblock form_help %} |
98 | 104 |
|
99 | | -{# Adjust order of elements in form row #} |
| 105 | +{# Adjust order of elements in form row, add fieldset for compound groups #} |
100 | 106 | {%- block form_row_render -%} |
101 | 107 | <div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}> |
102 | 108 | {% if compound %} |
103 | 109 | <fieldset class="tbxforms-fieldset"> |
104 | | - |
105 | 110 | {% endif %} |
106 | 111 | {{- form_label(form) -}} |
107 | 112 | {{- form_help(form) -}} |
|
113 | 118 | </div> |
114 | 119 | {%- endblock form_row_render -%} |
115 | 120 |
|
| 121 | +{# This is for single non-choice checkboxes (eg. Agree to Terms) #} |
116 | 122 | {% block checkbox_row %} |
117 | 123 | <div class="tbxforms-form-group"> |
118 | 124 | <div class="tbxforms-checkboxes"> |
|
138 | 144 | </div> |
139 | 145 | {%- endblock choice_widget_expanded -%} |
140 | 146 |
|
| 147 | +{# Add class to checkboxes #} |
141 | 148 | {%- block checkbox_widget -%} |
142 | 149 | <input type="checkbox" class="tbxforms-checkboxes__input" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
143 | 150 | {%- endblock checkbox_widget -%} |
144 | 151 |
|
| 152 | +{# Add class to radio buttons #} |
145 | 153 | {%- block radio_widget -%} |
146 | 154 | <input type="radio" class="govuk-radios__input" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
147 | 155 | {%- endblock radio_widget -%} |
|
155 | 163 | {{- parent() -}} |
156 | 164 | {%- endblock form_widget_simple -%} |
157 | 165 |
|
| 166 | +{# Add class to select boxes #} |
158 | 167 | {%- block choice_widget_collapsed -%} |
159 | 168 | {% set attr = attr|merge({'class': 'tbxforms-select'}) %} |
160 | 169 | {{- parent() -}} |
|
0 commit comments