3 {%- block form_widget -%}
5 {{- block('form_widget_compound') -}}
7 {{- block('form_widget_simple') -}}
9 {%- endblock form_widget -%}
11 {%- block form_widget_simple -%}
12 {%- set type = type|default('text') -%}
13 <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
14 {%- endblock form_widget_simple -%}
16 {%- block form_widget_compound -%}
17 <div {{ block('widget_container_attributes') }}>
18 {%- if form is rootform -%}
19 {{ form_errors(form) }}
21 {{- block('form_rows') -}}
22 {{- form_rest(form) -}}
24 {%- endblock form_widget_compound -%}
26 {%- block collection_widget -%}
27 {% if prototype is defined %}
28 {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%}
30 {{- block('form_widget') -}}
31 {%- endblock collection_widget -%}
33 {%- block textarea_widget -%}
34 <textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
35 {%- endblock textarea_widget -%}
37 {%- block choice_widget -%}
39 {{- block('choice_widget_expanded') -}}
41 {{- block('choice_widget_collapsed') -}}
43 {%- endblock choice_widget -%}
45 {%- block choice_widget_expanded -%}
46 {%- for child in form %}
47 <div class="row" {{ block('widget_container_attributes') }}>
48 {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}}
50 {{- form_widget(child) -}}
54 {%- endblock choice_widget_expanded -%}
56 {%- block choice_widget_collapsed -%}
57 {%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%}
58 {% set required = false %}
60 <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
61 {%- if placeholder is not none -%}
62 <option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</option>
64 {%- if preferred_choices|length > 0 -%}
65 {% set options = preferred_choices %}
66 {{- block('choice_widget_options') -}}
67 {%- if choices|length > 0 and separator is not none -%}
68 <option disabled="disabled">{{ separator }}</option>
71 {%- set options = choices -%}
72 {{- block('choice_widget_options') -}}
74 {%- endblock choice_widget_collapsed -%}
76 {%- block choice_widget_options -%}
77 {% for group_label, choice in options %}
78 {%- if choice is iterable -%}
79 <optgroup label="{{ choice_translation_domain is same as(false) ? group_label : group_label|trans({}, choice_translation_domain) }}">
80 {% set options = choice %}
81 {{- block('choice_widget_options') -}}
84 <option value="{{ choice.value }}"{% if choice.attr %}{% with { attr: choice.attr } %}{{ block('attributes') }}{% endwith %}{% endif %}{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice_translation_domain is same as(false) ? choice.label : choice.label|trans({}, choice_translation_domain) }}</option>
87 {%- endblock choice_widget_options -%}
89 {%- block checkbox_widget -%}
90 <input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
91 {%- endblock checkbox_widget -%}
93 {%- block radio_widget -%}
94 <input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
95 {%- endblock radio_widget -%}
97 {%- block datetime_widget -%}
98 {% if widget == 'single_text' %}
99 {{- block('form_widget_simple') -}}
101 <div {{ block('widget_container_attributes') }}>
102 {{- form_errors(form.date) -}}
103 {{- form_errors(form.time) -}}
104 {{- form_widget(form.date) -}}
105 {{- form_widget(form.time) -}}
108 {%- endblock datetime_widget -%}
110 {%- block date_widget -%}
111 {%- if widget == 'single_text' -%}
112 {{ block('form_widget_simple') }}
114 <div {{ block('widget_container_attributes') }}>
115 {{- date_pattern|replace({
116 '{{ year }}': form_widget(form.year),
117 '{{ month }}': form_widget(form.month),
118 '{{ day }}': form_widget(form.day),
122 {%- endblock date_widget -%}
124 {%- block time_widget -%}
125 {%- if widget == 'single_text' -%}
126 {{ block('form_widget_simple') }}
128 {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%}
129 <div {{ block('widget_container_attributes') }}>
130 {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
133 {%- endblock time_widget -%}
135 {%- block dateinterval_widget -%}
136 {%- if widget == 'single_text' -%}
137 {{- block('form_widget_simple') -}}
139 <div {{ block('widget_container_attributes') }}>
140 {{- form_errors(form) -}}
141 <table class="{{ table_class|default('') }}" role="presentation">
144 {%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}
145 {%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%}
146 {%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%}
147 {%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%}
148 {%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%}
149 {%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%}
150 {%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%}
155 {%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%}
156 {%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%}
157 {%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%}
158 {%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%}
159 {%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%}
160 {%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%}
161 {%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%}
165 {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
168 {%- endblock dateinterval_widget -%}
170 {%- block number_widget -%}
171 {# type="number" doesn't work with floats #}
172 {%- set type = type|default('text') -%}
173 {{ block('form_widget_simple') }}
174 {%- endblock number_widget -%}
176 {%- block integer_widget -%}
177 {%- set type = type|default('number') -%}
178 {{ block('form_widget_simple') }}
179 {%- endblock integer_widget -%}
181 {%- block money_widget -%}
182 {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
183 {%- endblock money_widget -%}
185 {%- block url_widget -%}
186 {%- set type = type|default('url') -%}
187 {{ block('form_widget_simple') }}
188 {%- endblock url_widget -%}
190 {%- block search_widget -%}
191 {%- set type = type|default('search') -%}
192 {{ block('form_widget_simple') }}
193 {%- endblock search_widget -%}
195 {%- block percent_widget -%}
196 {%- set type = type|default('text') -%}
197 {{ block('form_widget_simple') }} %
198 {%- endblock percent_widget -%}
200 {%- block password_widget -%}
201 {%- set type = type|default('password') -%}
202 {{ block('form_widget_simple') }}
203 {%- endblock password_widget -%}
205 {%- block hidden_widget -%}
206 {%- set type = type|default('hidden') -%}
207 {{ block('form_widget_simple') }}
208 {%- endblock hidden_widget -%}
210 {%- block email_widget -%}
211 {%- set type = type|default('email') -%}
212 {{ block('form_widget_simple') }}
213 {%- endblock email_widget -%}
215 {%- block range_widget -%}
216 {% set type = type|default('range') %}
217 {{- block('form_widget_simple') -}}
218 {%- endblock range_widget %}
220 {%- block button_widget -%}
221 {%- if label is empty -%}
222 {%- if label_format is not empty -%}
223 {% set label = label_format|replace({
227 {%- elseif label is same as(false) -%}
228 {% set translation_domain = false %}
230 {% set label = name|humanize %}
233 <button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</button>
234 {%- endblock button_widget -%}
236 {%- block submit_widget -%}
237 {%- set type = type|default('submit') -%}
238 {{ block('button_widget') }}
239 {%- endblock submit_widget -%}
241 {%- block reset_widget -%}
242 {%- set type = type|default('reset') -%}
243 {{ block('button_widget') }}
244 {%- endblock reset_widget -%}
246 {%- block tel_widget -%}
247 {%- set type = type|default('tel') -%}
248 {{ block('form_widget_simple') }}
249 {%- endblock tel_widget -%}
251 {%- block color_widget -%}
252 {%- set type = type|default('color') -%}
253 {{ block('form_widget_simple') }}
254 {%- endblock color_widget -%}
258 {%- block form_label -%}
259 {% if label is not same as(false) -%}
260 {% if not compound -%}
261 {% set label_attr = label_attr|merge({'for': id}) %}
264 {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
266 {% if label is empty -%}
267 {%- if label_format is not empty -%}
268 {% set label = label_format|replace({
273 {% set label = name|humanize %}
276 <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>
277 {%- if translation_domain is same as(false) -%}
278 {%- if label_html is same as(false) -%}
284 {%- if label_html is same as(false) -%}
285 {{- label|trans({}, translation_domain) -}}
287 {{- label|trans({}, translation_domain)|raw -}}
290 </{{ element|default('label') }}>
292 {%- endblock form_label -%}
294 {%- block button_label -%}{%- endblock -%}
298 {%- block repeated_row -%}
300 No need to render the errors here, as all errors are mapped
301 to the first child (see RepeatedTypeValidatorExtension).
303 {{- block('form_rows') -}}
304 {%- endblock repeated_row -%}
306 {%- block form_row -%}
308 {{- form_label(form) -}}
310 {{- form_widget(form) -}}
311 {%- if errors|length > 0 -%}
312 <div class="message error">
313 {{- form_errors(form) -}}
318 {%- endblock form_row -%}
320 {%- block button_row -%}
322 {{- form_widget(form) -}}
324 {%- endblock button_row -%}
326 {%- block hidden_row -%}
327 {{ form_widget(form) }}
328 {%- endblock hidden_row -%}
333 {{ form_start(form) }}
334 {{- form_widget(form) -}}
336 {%- endblock form -%}
338 {%- block form_start -%}
339 {%- do form.setMethodRendered() -%}
340 {% set method = method|upper %}
341 {%- if method in ["GET", "POST"] -%}
342 {% set form_method = method %}
344 {% set form_method = "POST" %}
346 <form name="{{ name }}" method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
347 {%- if form_method != method -%}
348 <input type="hidden" name="_method" value="{{ method }}" />
350 {%- if errors|length > 0 -%}
351 <header class="message error">
352 {{- form_errors(form) -}}
355 {%- endblock form_start -%}
357 {%- block form_end -%}
358 {%- if not render_rest is defined or render_rest -%}
359 {{ form_rest(form) }}
362 {%- endblock form_end -%}
364 {%- block form_errors -%}
365 {%- if errors|length > 0 -%}
367 {%- for error in errors -%}
368 <li>{{ error.message }}</li>
372 {%- endblock form_errors -%}
374 {%- block form_rest -%}
375 {% for child in form -%}
376 {% if not child.rendered %}
377 {{- form_row(child) -}}
381 {% if not form.methodRendered and form is rootform %}
382 {%- do form.setMethodRendered() -%}
383 {% set method = method|upper %}
384 {%- if method in ["GET", "POST"] -%}
385 {% set form_method = method %}
387 {% set form_method = "POST" %}
390 {%- if form_method != method -%}
391 <input type="hidden" name="_method" value="{{ method }}" />
394 {% endblock form_rest %}
398 {%- block form_rows -%}
399 {% for child in form %}
400 {{- form_row(child) -}}
402 {%- endblock form_rows -%}
404 {%- block widget_attributes -%}
405 id="{{ id }}" name="{{ full_name }}"
406 {%- if disabled %} disabled="disabled"{% endif -%}
407 {%- if required %} required="required"{% endif -%}
408 {{ block('attributes') }}
409 {%- endblock widget_attributes -%}
411 {%- block widget_container_attributes -%}
412 {%- if id is not empty %}id="{{ id }}"{% endif -%}
413 {{ block('attributes') }}
414 {%- endblock widget_container_attributes -%}
416 {%- block button_attributes -%}
417 id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%}
418 {{ block('attributes') }}
419 {%- endblock button_attributes -%}
421 {% block attributes -%}
422 {%- for attrname, attrvalue in attr -%}
424 {%- if attrname in ['placeholder', 'title'] -%}
425 {{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}"
426 {%- elseif attrvalue is same as(true) -%}
427 {{- attrname }}="{{ attrname }}"
428 {%- elseif attrvalue is not same as(false) -%}
429 {{- attrname }}="{{ attrvalue }}"
432 {%- endblock attributes -%}