3 {% block form_widget %}
6 {{ block('form_widget_compound') }}
8 {{ block('form_widget_simple') }}
11 {% endblock form_widget %}
13 {% block form_widget_simple %}
15 {% set type = type|default('text') %}
16 <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
18 {% endblock form_widget_simple %}
20 {% block form_widget_compound %}
22 <div {{ block('widget_container_attributes') }}>
23 {% if form.parent is empty %}
24 {{ form_errors(form) }}
26 {{ block('form_rows') }}
30 {% endblock form_widget_compound %}
32 {% block collection_widget %}
34 {% if prototype is defined %}
35 {% set attr = attr|merge({'data-prototype': form_row(prototype) }) %}
37 {{ block('form_widget') }}
39 {% endblock collection_widget %}
41 {% block textarea_widget %}
43 <textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
45 {% endblock textarea_widget %}
47 {% block choice_widget %}
50 {{ block('choice_widget_expanded') }}
52 {{ block('choice_widget_collapsed') }}
55 {% endblock choice_widget %}
57 {% block choice_widget_expanded %}
59 <div {{ block('widget_container_attributes') }}>
60 {% for child in form %}
61 {{ form_widget(child) }}
62 {{ form_label(child) }}
66 {% endblock choice_widget_expanded %}
68 {% block choice_widget_collapsed %}
70 <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
71 {% if empty_value is not none %}
72 <option {% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% else %} value=""{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
74 {% if preferred_choices|length > 0 %}
75 {% set options = preferred_choices %}
76 {{ block('choice_widget_options') }}
77 {% if choices|length > 0 and separator is not none %}
78 <option disabled="disabled">{{ separator }}</option>
81 {% set options = choices %}
82 {{ block('choice_widget_options') }}
85 {% endblock choice_widget_collapsed %}
87 {% block choice_widget_options %}
89 {% for group_label, choice in options %}
90 {% if choice is iterable %}
91 <optgroup label="{{ group_label|trans({}, translation_domain) }}">
92 {% set options = choice %}
93 {{ block('choice_widget_options') }}
96 <option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice.label|trans({}, translation_domain) }}</option>
100 {% endblock choice_widget_options %}
102 {% block checkbox_widget %}
104 <input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
106 {% endblock checkbox_widget %}
108 {% block radio_widget %}
110 <input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
112 {% endblock radio_widget %}
114 {% block datetime_widget %}
116 {% if widget == 'single_text' %}
117 {{ block('form_widget_simple') }}
119 <div {{ block('widget_container_attributes') }}>
120 {{ form_errors(form.date) }}
121 {{ form_errors(form.time) }}
122 {{ form_widget(form.date) }}
123 {{ form_widget(form.time) }}
127 {% endblock datetime_widget %}
129 {% block date_widget %}
131 {% if widget == 'single_text' %}
132 {{ block('form_widget_simple') }}
134 <div {{ block('widget_container_attributes') }}>
135 {{ date_pattern|replace({
136 '{{ year }}': form_widget(form.year),
137 '{{ month }}': form_widget(form.month),
138 '{{ day }}': form_widget(form.day),
143 {% endblock date_widget %}
145 {% block time_widget %}
147 {% if widget == 'single_text' %}
148 {{ block('form_widget_simple') }}
150 {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %}
151 <div {{ block('widget_container_attributes') }}>
152 {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
156 {% endblock time_widget %}
158 {% block number_widget %}
160 {# type="number" doesn't work with floats #}
161 {% set type = type|default('text') %}
162 {{ block('form_widget_simple') }}
164 {% endblock number_widget %}
166 {% block integer_widget %}
168 {% set type = type|default('number') %}
169 {{ block('form_widget_simple') }}
171 {% endblock integer_widget %}
173 {% block money_widget %}
175 {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
177 {% endblock money_widget %}
179 {% block url_widget %}
181 {% set type = type|default('url') %}
182 {{ block('form_widget_simple') }}
184 {% endblock url_widget %}
186 {% block search_widget %}
188 {% set type = type|default('search') %}
189 {{ block('form_widget_simple') }}
191 {% endblock search_widget %}
193 {% block percent_widget %}
195 {% set type = type|default('text') %}
196 {{ block('form_widget_simple') }} %
198 {% endblock percent_widget %}
200 {% block password_widget %}
202 {% set type = type|default('password') %}
203 {{ block('form_widget_simple') }}
205 {% endblock password_widget %}
207 {% block hidden_widget %}
209 {% set type = type|default('hidden') %}
210 {{ block('form_widget_simple') }}
212 {% endblock hidden_widget %}
214 {% block email_widget %}
216 {% set type = type|default('email') %}
217 {{ block('form_widget_simple') }}
219 {% endblock email_widget %}
221 {% block button_widget %}
223 {% if label is empty %}
224 {% set label = name|humanize %}
226 <button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button>
228 {% endblock button_widget %}
230 {% block submit_widget %}
232 {% set type = type|default('submit') %}
233 {{ block('button_widget') }}
235 {% endblock submit_widget %}
237 {% block reset_widget %}
239 {% set type = type|default('reset') %}
240 {{ block('button_widget') }}
242 {% endblock reset_widget %}
246 {% block form_label %}
248 {% if label is not sameas(false) %}
249 {% if not compound %}
250 {% set label_attr = label_attr|merge({'for': id}) %}
253 {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
255 {% if label is empty %}
256 {% set label = name|humanize %}
258 <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label>
261 {% endblock form_label %}
263 {% block button_label %}{% endblock %}
267 {% block repeated_row %}
270 No need to render the errors here, as all errors are mapped
271 to the first child (see RepeatedTypeValidatorExtension).
273 {{ block('form_rows') }}
275 {% endblock repeated_row %}
280 {{ form_label(form) }}
281 {{ form_errors(form) }}
282 {{ form_widget(form) }}
285 {% endblock form_row %}
287 {% block button_row %}
290 {{ form_widget(form) }}
293 {% endblock button_row %}
295 {% block hidden_row %}
296 {{ form_widget(form) }}
297 {% endblock hidden_row %}
303 {{ form_start(form) }}
304 {{ form_widget(form) }}
309 {% block form_start %}
311 {% set method = method|upper %}
312 {% if method in ["GET", "POST"] %}
313 {% set form_method = method %}
315 {% set form_method = "POST" %}
317 <form method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
318 {% if form_method != method %}
319 <input type="hidden" name="_method" value="{{ method }}" />
322 {% endblock form_start %}
326 {% if not render_rest is defined or render_rest %}
327 {{ form_rest(form) }}
331 {% endblock form_end %}
333 {% block form_enctype %}
335 {% if multipart %}enctype="multipart/form-data"{% endif %}
337 {% endblock form_enctype %}
339 {% block form_errors %}
341 {% if errors|length > 0 %}
343 {% for error in errors %}
344 <li>{{ error.message }}</li>
349 {% endblock form_errors %}
351 {% block form_rest %}
353 {% for child in form %}
354 {% if not child.rendered %}
355 {{ form_row(child) }}
359 {% endblock form_rest %}
363 {% block form_rows %}
365 {% for child in form %}
366 {{ form_row(child) }}
369 {% endblock form_rows %}
371 {% block widget_attributes %}
373 id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
374 {% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
376 {% endblock widget_attributes %}
378 {% block widget_container_attributes %}
380 {% if id is not empty %}id="{{ id }}" {% endif %}
381 {% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}
383 {% endblock widget_container_attributes %}
385 {% block button_attributes %}
387 id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif %}
388 {% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}
390 {% endblock button_attributes %}