|
4 | 4 | {# Custom block to list errors #} |
5 | 5 | {%- block form_error_summary -%} |
6 | 6 | {% if form is not valid %} |
7 | | - <div id="site-aria-alert" role="alert"> |
8 | | - <div class="govuk-error-summary rnib-error-summary" data-module="govuk-error-summary"> |
9 | | - <h2 class="govuk-error-summary__title rnib-error-summary__title"> |
10 | | - There are {{ form_all_errors(form) | length }} problems with this request |
11 | | - </h2> |
12 | | - <div class="govuk-error-summary__body rnib-error-summary__body"> |
13 | | - <ul class="govuk-error-summary__list rnib-error-summary__list"> |
14 | | - {% for error in form_all_errors(form) %} |
15 | | - <li><a href='#{{ error.id }}'>{{ error.message }}</a></li> |
16 | | - {% endfor %} |
17 | | - </ul> |
| 7 | + <div id="site-aria-alert" role="alert"> |
| 8 | + <div class="govuk-error-summary rnib-error-summary" data-module="govuk-error-summary"> |
| 9 | + <h2 class="govuk-error-summary__title rnib-error-summary__title"> |
| 10 | + There are {{ form_all_errors(form) | length }} problems with this request |
| 11 | + </h2> |
| 12 | + <div class="govuk-error-summary__body rnib-error-summary__body"> |
| 13 | + <ul class="govuk-error-summary__list rnib-error-summary__list"> |
| 14 | + {% for error in form_all_errors(form) %} |
| 15 | + <li><a href='#{{ error.id }}'>{{ error.message }}</a></li> |
| 16 | + {% endfor %} |
| 17 | + </ul> |
| 18 | + </div> |
18 | 19 | </div> |
19 | 20 | </div> |
20 | | - </div> |
21 | 21 | {% endif %} |
22 | 22 | {%- endblock form_error_summary -%} |
23 | 23 |
|
24 | 24 | {# Custom markup for field errors. Appears as error above each field #} |
25 | 25 | {%- block form_errors -%} |
26 | 26 | {%- if errors|length > 0 -%} |
27 | 27 | {% for error in errors %} |
28 | | - <span id="id_{{ id }}_error{{ loop.index }}" class="tbxforms-error-message">Error: {{ error.message }}</span> |
| 28 | + <span id="{{ id }}_error{{ loop.index }}" class="tbxforms-error-message">Error: {{ error.message }}</span> |
29 | 29 | {% endfor %} |
30 | 30 | {%- endif -%} |
31 | 31 | {%- endblock form_errors -%} |
|
74 | 74 | {% set label_attr = label_attr|merge({'class': 'tbxforms-label tbxforms-checkboxes__label'}) %} |
75 | 75 |
|
76 | 76 | <label{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
77 | | - {{- block('form_label_content') -}} |
| 77 | + {{- block('form_label_content') -}} |
78 | 78 | </label> |
79 | 79 | {%- endif -%} |
80 | 80 | {% endblock %} |
|
88 | 88 | {% set label_attr = label_attr|merge({'class': 'rnib-form-label rnib-form-label--option govuk-radios__label'}) %} |
89 | 89 |
|
90 | 90 | <label{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
91 | | - {{- block('form_label_content') -}} |
| 91 | + {{- block('form_label_content') -}} |
92 | 92 | </label> |
93 | 93 | {%- endif -%} |
94 | 94 | {% endblock %} |
95 | 95 |
|
96 | 96 | {# Custom markup for field hints #} |
97 | 97 | {% block form_help -%} |
98 | 98 | {%- if help -%} |
99 | | - <div id="id_{{ id }}_hint" class="rnib-form-hint"> |
| 99 | + <div id="{{ id }}_help" class="rnib-form-hint"> |
100 | 100 | {{- block('form_help_content') -}} |
101 | 101 | </div> |
102 | 102 | {%- endif -%} |
|
106 | 106 | {%- block form_row_render -%} |
107 | 107 | <div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}> |
108 | 108 | {% if compound %} |
109 | | - <fieldset class="tbxforms-fieldset"> |
110 | | - {% endif %} |
111 | | - {{- form_label(form) -}} |
112 | | - {{- form_help(form) -}} |
113 | | - {{- form_errors(form) -}} |
114 | | - {{- form_widget(form, widget_attr) -}} |
115 | | - {% if compound %} |
116 | | - </fieldset> |
| 109 | + <fieldset class="tbxforms-fieldset"> |
| 110 | + {% endif %} |
| 111 | + {{- form_label(form) -}} |
| 112 | + {{- form_help(form) -}} |
| 113 | + {{- form_errors(form) -}} |
| 114 | + {{- form_widget(form, widget_attr) -}} |
| 115 | + {% if compound %} |
| 116 | + </fieldset> |
117 | 117 | {% endif %} |
118 | 118 | </div> |
119 | 119 | {%- endblock form_row_render -%} |
120 | 120 |
|
121 | 121 | {# This is for single non-choice checkboxes (eg. Agree to Terms) #} |
122 | 122 | {% block checkbox_row %} |
123 | | -<div class="tbxforms-form-group"> |
124 | | - <div class="tbxforms-checkboxes"> |
125 | | - <div class="tbxforms-checkboxes__item"> |
126 | | - {{- form_widget(form, row_attr) -}} |
127 | | - {{- form_label(form) -}} |
| 123 | + <div class="tbxforms-form-group"> |
| 124 | + <div class="tbxforms-checkboxes"> |
| 125 | + <div class="tbxforms-checkboxes__item"> |
| 126 | + {{- form_widget(form, row_attr) -}} |
| 127 | + {{- form_label(form) -}} |
| 128 | + </div> |
128 | 129 | </div> |
129 | 130 | </div> |
130 | | -</div> |
131 | 131 | {% endblock checkbox_row %} |
132 | 132 |
|
133 | 133 | {# Add custom markup to checkbox / radio buttons in choice context #} |
|
183 | 183 | </button> |
184 | 184 | {%- endblock button_widget -%} |
185 | 185 |
|
| 186 | +{# Add class to textareas #} |
186 | 187 | {%- block textarea_widget -%} |
187 | 188 | {% set attr = attr|merge({'class': 'tbxforms-input tbxforms-textarea'}) %} |
188 | 189 | {{- parent() -}} |
189 | 190 | {%- endblock textarea_widget -%} |
190 | 191 |
|
| 192 | +{# Customise markup and classes for birthday field #} |
191 | 193 | {% block birthday_widget %} |
192 | 194 | {% if widget == 'single_text' %} |
193 | 195 | {{- block('form_widget_simple') -}} |
|
206 | 208 |
|
207 | 209 | {% endif %} |
208 | 210 | {% endblock birthday_widget %} |
| 211 | + |
| 212 | +{# Remove the required attribute from the element (disable frontend validation) #} |
| 213 | +{%- block widget_attributes -%} |
| 214 | + id="{{ id }}" name="{{ full_name }}" |
| 215 | + {%- if disabled %} disabled="disabled"{% endif -%} |
| 216 | + {% set attr = attr|merge({'required': false}) %} |
| 217 | + {{ block('attributes') }} |
| 218 | +{%- endblock widget_attributes -%} |
| 219 | + |
0 commit comments