-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
foundation_5_layout.html.twig
328 lines (297 loc) · 11.7 KB
/
foundation_5_layout.html.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
{% extends "form_div_layout.html.twig" %}
{# Based on Foundation 5 Doc #}
{# Widgets #}
{% block form_widget_simple -%}
{% if errors|length > 0 -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{{- parent() -}}
{%- endblock form_widget_simple %}
{% block textarea_widget -%}
{% if errors|length > 0 -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{{- parent() -}}
{%- endblock textarea_widget %}
{% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' button')|trim}) %}
{{- parent() -}}
{%- endblock button_widget %}
{% block money_widget -%}
<div class="row collapse">
{% set prepend = '{{' == money_pattern[0:2] %}
{% if not prepend %}
<div class="small-3 large-2 columns">
<span class="prefix">{{ money_pattern|form_encode_currency }}</span>
</div>
{% endif %}
<div class="small-9 large-10 columns">
{{- block('form_widget_simple') -}}
</div>
{% if prepend %}
<div class="small-3 large-2 columns">
<span class="postfix">{{ money_pattern|form_encode_currency }}</span>
</div>
{% endif %}
</div>
{%- endblock money_widget %}
{% block percent_widget -%}
<div class="row collapse">
<div class="small-9 large-10 columns">
{{- block('form_widget_simple') -}}
</div>
<div class="small-3 large-2 columns">
<span class="postfix">%</span>
</div>
</div>
{%- endblock percent_widget %}
{% block datetime_widget -%}
{% if widget == 'single_text' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %}
<div class="row">
<div class="large-7 columns">{{ form_errors(form.date) }}</div>
<div class="large-5 columns">{{ form_errors(form.time) }}</div>
</div>
<div {{ block('widget_container_attributes') }}>
<div class="large-7 columns">{{ form_widget(form.date, { datetime: true } ) }}</div>
<div class="large-5 columns">{{ form_widget(form.time, { datetime: true } ) }}</div>
</div>
{% endif %}
{%- endblock datetime_widget %}
{% block date_widget -%}
{% if widget == 'single_text' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %}
{% if datetime is not defined or not datetime %}
<div {{ block('widget_container_attributes') }}>
{% endif %}
{{- date_pattern|replace({
'{{ year }}': '<div class="large-4 columns">' ~ form_widget(form.year) ~ '</div>',
'{{ month }}': '<div class="large-4 columns">' ~ form_widget(form.month) ~ '</div>',
'{{ day }}': '<div class="large-4 columns">' ~ form_widget(form.day) ~ '</div>',
})|raw -}}
{% if datetime is not defined or not datetime %}
</div>
{% endif %}
{% endif %}
{%- endblock date_widget %}
{% block time_widget -%}
{% if widget == 'single_text' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %}
{% if datetime is not defined or false == datetime %}
<div {{ block('widget_container_attributes') -}}>
{% endif %}
{% if with_seconds %}
<div class="large-4 columns">{{ form_widget(form.hour) }}</div>
<div class="large-4 columns">
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">:</span>
</div>
<div class="small-9 large-10 columns">
{{ form_widget(form.minute) }}
</div>
</div>
</div>
<div class="large-4 columns">
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">:</span>
</div>
<div class="small-9 large-10 columns">
{{ form_widget(form.second) }}
</div>
</div>
</div>
{% else %}
<div class="large-6 columns">{{ form_widget(form.hour) }}</div>
<div class="large-6 columns">
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">:</span>
</div>
<div class="small-9 large-10 columns">
{{ form_widget(form.minute) }}
</div>
</div>
</div>
{% endif %}
{% if datetime is not defined or false == datetime %}
</div>
{% endif %}
{% endif %}
{%- endblock time_widget %}
{% block choice_widget_collapsed -%}
{% if errors|length > 0 -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{% if multiple -%}
{% set attr = attr|merge({style: (attr.style|default('') ~ ' height: auto; background-image: none;')|trim}) %}
{% endif %}
{% if required and placeholder is none and not placeholder_in_choices and not multiple -%}
{% set required = false %}
{%- endif -%}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple" data-customforms="disabled"{% endif %}>
{% if placeholder is not none -%}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain) }}</option>
{%- endif %}
{%- if preferred_choices|length > 0 -%}
{% set options = preferred_choices %}
{{- block('choice_widget_options') -}}
{% if choices|length > 0 and separator is not none -%}
<option disabled="disabled">{{ separator }}</option>
{%- endif %}
{%- endif -%}
{% set options = choices -%}
{{- block('choice_widget_options') -}}
</select>
{%- endblock choice_widget_collapsed %}
{% block choice_widget_expanded -%}
{% if '-inline' in label_attr.class|default('') %}
<ul class="inline-list">
{% for child in form %}
<li>{{ form_widget(child, {
parent_label_class: label_attr.class|default(''),
}) }}</li>
{% endfor %}
</ul>
{% else %}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{{ form_widget(child, {
parent_label_class: label_attr.class|default(''),
}) }}
{% endfor %}
</div>
{% endif %}
{%- endblock choice_widget_expanded %}
{% block checkbox_widget -%}
{% set parent_label_class = parent_label_class|default('') %}
{% if errors|length > 0 -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{% if 'checkbox-inline' in parent_label_class %}
{{ form_label(form, null, { widget: parent() }) }}
{% else %}
<div class="checkbox">
{{ form_label(form, null, { widget: parent() }) }}
</div>
{% endif %}
{%- endblock checkbox_widget %}
{% block radio_widget -%}
{% set parent_label_class = parent_label_class|default('') %}
{% if 'radio-inline' in parent_label_class %}
{{ form_label(form, null, { widget: parent() }) }}
{% else %}
{% if errors|length > 0 -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
<div class="radio">
{{ form_label(form, null, { widget: parent() }) }}
</div>
{% endif %}
{%- endblock radio_widget %}
{# Labels #}
{% block form_label -%}
{% if errors|length > 0 -%}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{{- parent() -}}
{%- endblock form_label %}
{% block choice_label -%}
{% if errors|length > 0 -%}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #}
{% set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) %}
{{- block('form_label') -}}
{%- endblock choice_label %}
{% block checkbox_label -%}
{{- block('checkbox_radio_label') -}}
{%- endblock checkbox_label %}
{% block radio_label -%}
{{- block('checkbox_radio_label') -}}
{%- endblock radio_label %}
{% block checkbox_radio_label -%}
{% if required %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% if errors|length > 0 -%}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %}
{% endif %}
{% if parent_label_class is defined %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %}
{% endif %}
{% if label is empty %}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ widget|raw }}
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
</label>
{%- endblock checkbox_radio_label %}
{# Rows #}
{% block form_row -%}
<div class="row">
<div class="large-12 columns{% if (not compound or force_error|default(false)) and not valid %} error{% endif %}">
{{ form_label(form) }}
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
{%- endblock form_row %}
{% block choice_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{%- endblock choice_row %}
{% block date_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{%- endblock date_row %}
{% block time_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{%- endblock time_row %}
{% block datetime_row -%}
{% set force_error = true %}
{{ block('form_row') }}
{%- endblock datetime_row %}
{% block checkbox_row -%}
<div class="row">
<div class="large-12 columns{% if not valid %} error{% endif %}">
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
{%- endblock checkbox_row %}
{% block radio_row -%}
<div class="row">
<div class="large-12 columns{% if not valid %} error{% endif %}">
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
{%- endblock radio_row %}
{# Errors #}
{% block form_errors -%}
{% if errors|length > 0 -%}
{% if form is not rootform %}<small class="error">{% else %}<div data-alert class="alert-box alert">{% endif %}
{%- for error in errors -%}
{{ error.message }}
{% if not loop.last %}, {% endif %}
{%- endfor -%}
{% if form is not rootform %}</small>{% else %}</div>{% endif %}
{%- endif %}
{%- endblock form_errors %}