|
35 | 35 | {%- endblock form_start -%} |
36 | 36 |
|
37 | 37 | {%- block form_row -%} |
38 | | - {% if expanded %} |
39 | | - <fieldset class="tbxforms-fieldset"> |
40 | | - {% endif %} |
41 | 38 | {% set row_attr = row_attr|merge({'class': 'tbxforms-form-group'}) %} |
42 | 39 | {%- if errors|length > 0 -%} |
43 | 40 | {% set class = row_attr.class ~ ' tbxforms-form-group--error' %} |
44 | 41 | {% set row_attr = row_attr|merge({'class': class}) %} |
45 | 42 | {%- endif -%} |
46 | 43 | {{- parent() -}} |
47 | | - {% if expanded %} |
48 | | - </fieldset> |
49 | | - {% endif %} |
50 | 44 | {%- endblock form_row -%} |
51 | 45 |
|
52 | 46 | {# Field rows become fieldsets on checkbox and radio buttons, so make the label the legend #} |
53 | 47 | {%- block form_label -%} |
54 | 48 | {% if label is not same as(false) -%} |
55 | | - {% if expanded %} |
56 | | - <legend>{{- block('form_label_content') -}}</legend> |
57 | | - {% else %} |
| 49 | + {%- if compound -%} |
| 50 | + <legend><h2 class="rnib-form-label__wrapper">{{- block('form_label_content') -}}</h2></legend> |
| 51 | + {%- else -%} |
58 | 52 | {% if not compound -%} |
59 | 53 | {% set label_attr = label_attr|merge({for: id}) %} |
60 | 54 | {%- endif -%} |
61 | 55 | {% set label_attr = label_attr|merge({'class': 'rnib-form-label'}) %} |
62 | 56 | <h2 class="rnib-form-label__wrapper"> |
63 | | - <{{ element|default('label') }}{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
| 57 | + <label{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
64 | 58 | {{- block('form_label_content') -}} |
65 | | - </{{ element|default('label') }}> |
| 59 | + </label> |
66 | 60 | </h2> |
67 | | - {% endif %} |
| 61 | + {%- endif -%} |
68 | 62 | {%- endif -%} |
69 | 63 | {%- endblock form_label -%} |
70 | 64 |
|
|
75 | 69 | {%- endif -%} |
76 | 70 | {% set label_attr = label_attr|merge({'class': 'tbxforms-label tbxforms-checkboxes__label'}) %} |
77 | 71 |
|
78 | | - <{{ element|default('label') }}{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
| 72 | + <label{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
79 | 73 | {{- block('form_label_content') -}} |
80 | | - </{{ element|default('label') }}> |
| 74 | + </label> |
81 | 75 | {%- endif -%} |
82 | 76 | {% endblock %} |
83 | 77 |
|
|
88 | 82 | {%- endif -%} |
89 | 83 | {% set label_attr = label_attr|merge({'class': 'rnib-form-label rnib-form-label--option govuk-radios__label'}) %} |
90 | 84 |
|
91 | | - <{{ element|default('label') }}{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
| 85 | + <label{% if label_attr %}{% with {attr: label_attr} %}{{ block('attributes') }}{% endwith %}{% endif %}> |
92 | 86 | {{- block('form_label_content') -}} |
93 | | - </{{ element|default('label') }}> |
| 87 | + </label> |
94 | 88 | {%- endif -%} |
95 | 89 | {% endblock %} |
96 | 90 |
|
|
105 | 99 | {# Adjust order of elements in form row #} |
106 | 100 | {%- block form_row_render -%} |
107 | 101 | <div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}> |
| 102 | + {% if compound %} |
| 103 | + <fieldset class="tbxforms-fieldset"> |
| 104 | + |
| 105 | + {% endif %} |
108 | 106 | {{- form_label(form) -}} |
109 | 107 | {{- form_help(form) -}} |
110 | 108 | {{- form_errors(form) -}} |
111 | 109 | {{- form_widget(form, widget_attr) -}} |
| 110 | + {% if compound %} |
| 111 | + </fieldset> |
| 112 | + {% endif %} |
112 | 113 | </div> |
113 | 114 | {%- endblock form_row_render -%} |
114 | 115 |
|
| 116 | +{% block checkbox_row %} |
| 117 | +<div class="tbxforms-form-group"> |
| 118 | + <div class="tbxforms-checkboxes"> |
| 119 | + <div class="tbxforms-checkboxes__item"> |
| 120 | + {{- form_widget(form, row_attr) -}} |
| 121 | + {{- form_label(form) -}} |
| 122 | + </div> |
| 123 | + </div> |
| 124 | +</div> |
| 125 | +{% endblock checkbox_row %} |
| 126 | + |
115 | 127 | {# Checkbox / Radio buttons #} |
116 | 128 | {%- block choice_widget_expanded -%} |
117 | 129 | <div {{ block('widget_container_attributes') }}> |
|
125 | 137 | </div> |
126 | 138 | </div> |
127 | 139 | {%- endblock choice_widget_expanded -%} |
| 140 | + |
| 141 | +{%- block checkbox_widget -%} |
| 142 | + <input type="checkbox" class="tbxforms-checkboxes__input" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
| 143 | +{%- endblock checkbox_widget -%} |
| 144 | + |
| 145 | +{%- block radio_widget -%} |
| 146 | + <input type="radio" class="govuk-radios__input" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
| 147 | +{%- endblock radio_widget -%} |
| 148 | + |
| 149 | +{# Add classes to input elements #} |
| 150 | +{%- block form_widget_simple -%} |
| 151 | + {% set attr = attr|merge({'class': 'tbxforms-input'}) %} |
| 152 | + {%- if type == 'text' -%} |
| 153 | + {%- set attr = attr|merge({'class': 'tbxforms-input tbxforms-input--text'}) -%} |
| 154 | + {% endif %} |
| 155 | + {{- parent() -}} |
| 156 | +{%- endblock form_widget_simple -%} |
| 157 | + |
| 158 | +{%- block choice_widget_collapsed -%} |
| 159 | + {% set attr = attr|merge({'class': 'tbxforms-select'}) %} |
| 160 | + {{- parent() -}} |
| 161 | +{%- endblock choice_widget_collapsed -%} |
0 commit comments