-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathbootstrap.html.twig
More file actions
915 lines (803 loc) · 35.5 KB
/
bootstrap.html.twig
File metadata and controls
915 lines (803 loc) · 35.5 KB
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
{% use "form_div_layout.html.twig" %}
{# Widgets #}
{% block form_widget %}
{% spaceless %}
{% if compound %}
{{ block('form_widget_compound') }}
{% else %}
{{ block('form_widget_simple') }}
{% endif %}
{% endspaceless %}
{% endblock form_widget %}
{% block form_widget_simple %}
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if simple_col is not defined and bootstrap_get_simple_col() %}
{% set simple_col = bootstrap_get_simple_col() %}
{% endif %}
{% if attr.simple_col is defined and attr.simple_col is not empty %}
{% set simple_col = attr.simple_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if attr.style is defined and attr.style is not empty %}
{% set style = attr.style %}
{% endif %}
{% if simple_col is defined and simple_col %}
<div class="col-{{ col_size }}-{{ simple_col }}">
{% endif %}
{% set type = type|default('text') %}
{% if style == 'inline' and (attr.placeholder is not defined or attr.placeholder is empty) and label is not sameas(false) %}
{% if label is empty %}
{% set attr = attr|merge({ 'placeholder': name|humanize }) %}
{% else %}
{% set attr = attr|merge({ 'placeholder': label}) %}
{% endif %}
{% endif %}
{% if static_control is defined and static_control == true %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control-static')|trim }) %}
<p id="{{ id }}" {%- for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ value }}</p>
{%- else -%}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}>
{%- endif %}
{% if simple_col is defined %}
</div>
{% endif %}
{% endspaceless %}
{% endblock form_widget_simple %}
{% block form_widget_compound %}
{% spaceless %}
<div {{ block('widget_container_attributes') }}>
{% if form.parent is empty %}
{{ block('global_form_errors') }}
{% endif %}
{{ block('form_rows') }}
{{ form_rest(form) }}
</div>
{% endspaceless %}
{% endblock form_widget_compound %}
{% block collection_widget %}
{% spaceless %}
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': form_row(prototype) }) %}
{% endif %}
{{ block('form_widget') }}
{% endspaceless %}
{% endblock collection_widget %}
{% block bootstrap_collection_widget %}
{% spaceless %}
{% if prototype is defined %}
{% set prototype_vars = {} %}
{% if style is defined %}
{% set prototype_vars = prototype_vars|merge({'style': style}) %}
{% endif %}
{% set prototype_html = '<div class="col-xs-' ~ form.vars.sub_widget_col ~ '">' ~ form_widget(prototype, prototype_vars) ~ '</div>' %}
{% if form.vars.allow_delete %}
{% set prototype_html = prototype_html ~ '<div class="col-xs-' ~ form.vars.button_col ~ '"><a href="#" class="btn btn-danger btn-sm" data-removefield="collection" data-field="__id__">' ~ form.vars.delete_button_text|trans({}, translation_domain)|parse_icons|raw ~ '</a></div>' %}
{% endif %}
{% set prototype_html = '<div class="row">' ~ prototype_html ~ '</div>' %}
{% set attr = attr|merge({'data-prototype': prototype_html }) %}
{% set attr = attr|merge({'data-prototype-name': prototype_name }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
<ul class="bc-collection list-unstyled">
{% for field in form %}
<li>
<div class="row">
<div class="col-xs-{{ form.vars.sub_widget_col }}">
{{ form_widget(field) }}
{{ form_errors(field) }}
</div>
{% if form.vars.allow_delete %}
<div class="col-xs-{{ form.vars.button_col }}">
<a href="#" class="btn btn-danger btn-sm" data-removefield="collection" data-field="{{ field.vars.id }}">{{ form.vars.delete_button_text|trans({}, translation_domain)|parse_icons|raw }}</a>
</div>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
{% if form.vars.allow_add %}
<a href="#" class="btn btn-primary btn-sm" data-addfield="collection" data-collection="{{ form.vars.id }}" data-prototype-name="{{ prototype_name }}">{{ form.vars.add_button_text|trans({}, translation_domain)|parse_icons|raw }}</a>
{% endif %}
</div>
{% endspaceless %}
{% endblock bootstrap_collection_widget %}
{% block textarea_widget %}
{% spaceless %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.simple_col is defined and attr.simple_col is not empty %}
{% set simple_col = attr.simple_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if simple_col is defined %}
<div class="col-{{ col_size }}-{{ simple_col }}">
{% endif %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{% if simple_col is defined %}
</div>
{% endif %}
{% endspaceless %}
{% endblock textarea_widget %}
{% block file_widget %}
{% spaceless %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.simple_col is defined and attr.simple_col is not empty %}
{% set simple_col = attr.simple_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if simple_col is defined %}
<div class="col-{{ col_size }}-{{ simple_col }}">
{% endif %}
<input type="file" {{ block('widget_attributes') }}>
{% if simple_col is defined %}
</div>
{% endif %}
{% endspaceless %}
{% endblock file_widget %}
{% block choice_widget %}
{% spaceless %}
{% if expanded %}
{{ block('choice_widget_expanded') }}
{% else %}
{{ block('choice_widget_collapsed') }}
{% endif %}
{% endspaceless %}
{% endblock choice_widget %}
{% block choice_widget_expanded %}
{% spaceless %}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{% if multiple %}
{{ checkbox_row(child, { 'no_form_group': true, 'inline' : (attr.inline is defined and attr.inline), 'label_attr': label_attr }) }}
{% else %}
{{ radio_row(child, { 'no_form_group': true, 'inline' : (attr.inline is defined and attr.inline), 'label_attr': label_attr }) }}
{% endif %}
{% endfor %}
</div>
{% endspaceless %}
{% endblock choice_widget_expanded %}
{% block choice_widget_collapsed %}
{% spaceless %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{% if empty_value is not none %}
<option {% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% endif %} value="">{{ empty_value|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>
{% endspaceless %}
{% endblock choice_widget_collapsed %}
{% block choice_widget_options %}
{% spaceless %}
{% for group_label, choice in options %}
{% if choice is iterable %}
<optgroup label="{{ group_label|trans({}, translation_domain) }}">
{% set options = choice %}
{{ block('choice_widget_options') }}
</optgroup>
{% else %}
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice.label|trans({}, translation_domain) }}</option>
{% endif %}
{% endfor %}
{% endspaceless %}
{% endblock choice_widget_options %}
{% block checkbox_row %}
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if attr.style is defined and attr.style is not empty %}
{% set style = attr.style %}
{% endif %}
{% set class = '' %}
{% if align_with_widget is defined or attr.align_with_widget is defined %}
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %}
{% set label_col = label_col|default(bootstrap_get_label_col()) %}
{% set class = 'col-' ~ col_size ~ '-' ~ widget_col ~ ' col-' ~ col_size ~ '-offset-' ~ label_col %}
<div class="form-group {% if form.vars.errors|length > 0 %} has-error{% endif %}">
<div class="{{ class }}">
{% elseif no_form_group is not defined or no_form_group == false %}
<div class="form-group{% if form.vars.errors|length > 0 %} has-error{% endif %}">
{% endif %}
{%set checkboxdata %}
{% if label is not sameas(false) %}
{% if not compound %}
{% set label_attr = label_attr|merge({'for': id}) %}
{% endif %}
{% if inline is defined and inline %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' checkbox-inline')|trim}) %}
{% endif %}
{% if required %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% if label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ block('checkbox_widget') }}
{{ label|trans({}, translation_domain)|raw -}}
</label>
{% else %}
{{ block('checkbox_widget') }}
{% endif %}
{{ form_errors(form) }}
{% endset %}
{% if inline is defined and inline %}
{{ checkboxdata|raw }}
{% else%}
<div class="checkbox">{{ checkboxdata|raw }}</div>
{% endif %}
{{ block('form_help') }}
{% if align_with_widget is defined or attr.align_with_widget is defined %}
</div>
</div>
{% elseif no_form_group is not defined or no_form_group == false %}
</div>
{% endif %}
{% if style == 'inline' %} {% endif %}
{% endspaceless %}
{% endblock checkbox_row %}
{% block radio_row %}
{% spaceless %}
{% set class = '' %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if align_with_widget is defined or attr.align_with_widget is defined %}
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %}
{% set label_col = label_col|default(bootstrap_get_label_col()) %}
{% set class = ' col-'~ col_size ~ '-' ~ widget_col ~ ' col-' ~ col_size ~ '-offset-' ~ label_col %}
<div class="form-group {% if form.vars.errors|length > 0 %} has-error{% endif %}">
<div class="{{ class }}">
{% elseif no_form_group is not defined or no_form_group == false %}
<div class="form-group{% if form.vars.errors|length > 0 %} has-error{% endif %}">
{% endif %}
{%set radiodata %}
{% if label is not sameas(false) %}
{% if not compound %}
{% set label_attr = label_attr|merge({'for': id}) %}
{% endif %}
{% if inline is defined and inline %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' radio-inline')|trim}) %}
{% endif %}
{% if required %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% if label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ block('radio_widget') }}
{{ label|trans({}, translation_domain)|raw -}}
</label>
{% else %}
{{ block('radio_widget') }}
{% endif %}
{{ form_errors(form) }}
{% endset %}
{% if inline is defined and inline %}
{{ radiodata|raw }}
{% else%}
<div class="radio">{{ radiodata|raw }}</div>
{% endif %}
{{ block('form_help') }}
{% if align_with_widget is defined or attr.align_with_widget is defined %}
</div>
</div>
{% elseif no_form_group is not defined or no_form_group == false %}
</div>
{% endif %}
{% endspaceless %}
{% endblock radio_row %}
{% block checkbox_widget %}
{% spaceless %}
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{% endspaceless %}
{% endblock checkbox_widget %}
{% block radio_widget %}
{% spaceless %}
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{% endspaceless %}
{% endblock radio_widget %}
{% block datetime_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% set attr = attr|merge({ 'class': 'bootstrap-datetime' }) %}
<div {{ block('widget_container_attributes') }}>
{{ form_widget(form.date) }}
{{ form_widget(form.time) }}
{{ form_errors(form.date) }}
{{ form_errors(form.time) }}
</div>
{% endif %}
{% endspaceless %}
{% endblock datetime_widget %}
{% block date_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% set attr = attr|merge({ 'class': 'bootstrap-date' }) %}
<div {{ block('widget_container_attributes') }}>
{{ date_pattern|replace({
'{{ year }}': form_widget(form.year),
'{{ month }}': form_widget(form.month),
'{{ day }}': form_widget(form.day),
})|raw }}
</div>
{% endif %}
{% endspaceless %}
{% endblock date_widget %}
{% block time_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %}
{% set attr = attr|merge({ 'class': 'bootstrap-time' }) %}
<div {{ block('widget_container_attributes') }}>
{{ form_widget(form.hour, vars) }}
{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}
{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
</div>
{% endif %}
{% endspaceless %}
{% endblock time_widget %}
{% block number_widget %}
{% spaceless %}
{# type="number" doesn't work with floats #}
{% set type = type|default('text') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock number_widget %}
{% block integer_widget %}
{% spaceless %}
{% set type = type|default('number') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock integer_widget %}
{% block money_widget %}
{% spaceless %}
<div class="input-group">
{{ money_pattern|replace({
'{{ widget }}': block('form_widget_simple'),
'{{ tag_start }}': '<span class="input-group-addon">',
'{{ tag_end }}': '</span>'
})|raw }}
</div>
{% endspaceless %}
{% endblock money_widget %}
{% block url_widget %}
{% spaceless %}
{% set type = type|default('url') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock url_widget %}
{% block search_widget %}
{% spaceless %}
{% set type = type|default('search') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock search_widget %}
{% block percent_widget %}
{% spaceless %}
{% set type = type|default('text') %}
<div class="input-group">
{{ block('form_widget_simple') }}
<span class="input-group-addon">%</span>
</div>
{% endspaceless %}
{% endblock percent_widget %}
{% block password_widget %}
{% spaceless %}
{% set type = type|default('password') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock password_widget %}
{% block hidden_widget %}
{% spaceless %}
{% set type = type|default('hidden') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock hidden_widget %}
{% block email_widget %}
{% spaceless %}
{% set type = type|default('email') %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock email_widget %}
{% block button_widget %}
{% spaceless %}
{% if label is empty and label is not sameas(false) %}
{% set label = name|humanize %}
{% endif %}
{% if type is defined and type == 'submit' %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~button_class|default('primary'))|trim }) %}
{% else %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~button_class|default('default'))|trim }) %}
{% endif %}
{% if as_link is defined and as_link == true %}
<a {{ block('button_attributes') }}>{% if attr.icon is defined and attr.icon != '' %}{{ icon(attr.icon) }}{% endif %}{{ label|trans({}, translation_domain) }}</a>
{% else %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{% if attr.icon is defined and attr.icon != '' %}{{ icon(attr.icon) }}{% endif %}{{ label|trans({}, translation_domain) }}</button>
{% endif %}
{% endspaceless %}
{% endblock button_widget %}
{% block submit_widget %}
{% spaceless %}
{% set type = type|default('submit') %}
{{ block('button_widget') }}
{% endspaceless %}
{% endblock submit_widget %}
{% block reset_widget %}
{% spaceless %}
{% set type = type|default('reset') %}
{{ block('button_widget') }}
{% endspaceless %}
{% endblock reset_widget %}
{% block form_actions_widget %}
{% for button in form.children %}
{{ form_widget(button) }} {# this needs to be here due to https://github.com/twbs/bootstrap/issues/3245 #}
{% endfor %}
{% endblock %}
{% block bs_static_widget %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control-static')|trim }) %}
<p id="{{ id }}" {%- for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ value }}</p>
{% endblock %}
{# Labels #}
{% block form_label %}
{% spaceless %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if label is not sameas(false) %}
{% set style = style|default(bootstrap_get_style()) %}
{% set label_col = label_col|default(bootstrap_get_label_col()) %}
{% if attr.style is defined and attr.style is not empty %}
{% set style = attr.style %}
{% endif %}
{% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' control-label')|trim }) %}
{% if style == 'horizontal' %}
{% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' col-' ~ col_size ~ '-' ~ label_col)|trim }) %}
{% elseif style == 'inline' %}
{% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' sr-only')|trim }) %}
{% endif %}
{% if not compound %}
{% set label_attr = label_attr|merge({'for': id}) %}
{% endif %}
{% if required %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% if label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain)|raw }}</label>
{% endif %}
{% endspaceless %}
{% endblock form_label %}
{% block button_label %}{% endblock %}
{# Rows #}
{% block repeated_row %}
{% spaceless %}
{#
No need to render the errors here, as all errors are mapped
to the first child (see RepeatedTypeValidatorExtension).
#}
{{ block('form_rows') }}
{% endspaceless %}
{% endblock repeated_row %}
{% block form_row %}
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% if label is sameas(false) and label_col is defined %}
{% set widget_col = widget_col + label_col %}
{% endif %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if attr.style is defined and attr.style is not empty %}
{% set style = attr.style %}
{% endif %}
{% set label_col = label_col|default(bootstrap_get_label_col()) %}
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %}
<div class="form-group{% if form.vars.errors|length > 0 %} has-error{% endif %}">
{% if style == 'horizontal' %}
{{ form_label(form) }}
<div class="col-{{ col_size }}-{{ widget_col }}">
{{ block('form_input_group') }}
{{ block('form_help') }}
{{ form_errors(form) }}
</div>
{% else %}
{{ form_label(form) }}
{{ block('form_input_group') }}
{{ block('form_help') }}
{{ form_errors(form) }}
{% endif %}
</div>
{% if style == 'inline' %} {% endif %}
{% endspaceless %}
{% endblock form_row %}
{% block form_input_group %}
{% spaceless %}
{% if attr.input_group is defined and attr.input_group is not empty %}
{% set input_group = attr.input_group %}
{% endif %}
{% set input_group = input_group|default({}) %}
{% if input_group is not empty %}
{% set ig_size_class = '' %}
{% if input_group.size is defined and input_group.size == 'large' %}
{% set ig_size_class = ' input-group-lg' %}
{% endif %}
{% if input_group.size is defined and input_group.size == 'small' %}
{% set ig_size_class = ' input-group-sm' %}
{% endif %}
<div class="input-group{{ ig_size_class }}">
{% if input_group.prepend is defined and input_group.prepend is not empty %}
<span class="input-group-addon">{{ input_group.prepend|raw|parse_icons }}</span>
{% endif %}
{% if input_group.button_prepend is defined and input_group.button_prepend is not empty %}
<span class="input-group-btn">{{ form_widget(input_group_button_prepend) }}</span>
{% endif %}
{{ form_widget(form) }}
{% if input_group.button_append is defined and input_group.button_append is not empty %}
<span class="input-group-btn">{{ form_widget(input_group_button_append) }}</span>
{% endif %}
{% if input_group.append is defined and input_group.append is not empty %}
<span class="input-group-addon">{{ input_group.append|raw|parse_icons }}</span>
{% endif %}
</div>
{% else %}
{{ form_widget(form) }}
{% endif %}
{% endspaceless %}
{% endblock form_input_group %}
{% block form_help %}
{% spaceless %}
{% if attr.help_text is defined and attr.help_text is not empty %}
{% set help_text = attr.help_text %}
{% endif %}
{% set help_text = help_text|default('') %}
{% if help_text is not empty %}
<span class="help-block">{{ help_text|trans({}, translation_domain) }}</span>
{% endif %}
{% endspaceless %}
{% endblock form_help %}
{% block button_row %}
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}
{% set col_size = col_size|default(bootstrap_get_col_size()) %}
{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}
{% if attr.col_size is defined and attr.col_size is not empty %}
{% set col_size = attr.col_size %}
{% endif %}
{% if attr.style is defined and attr.style is not empty %}
{% set style = attr.style %}
{% endif %}
{% set label_col = label_col|default(bootstrap_get_label_col()) %}
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %}
<div class="form-group">
{% if style == 'horizontal' %}
<div class="col-{{ col_size }}-offset-{{ label_col }} col-{{ col_size }}-{{ widget_col }}">
{% endif %}
{{ form_widget(form) }}
{% if style == 'horizontal' %}
</div>
{% endif %}
</div>
{% endspaceless %}
{% endblock button_row %}
{% block hidden_row %}
{{ form_widget(form) }}
{% endblock hidden_row %}
{% block form_actions_row %}
{{ block('button_row') }}
{% endblock %}
{# Misc #}
{% block form %}
{% spaceless %}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
{% endspaceless %}
{% endblock form %}
{% block form_start %}
{% spaceless %}
{{ bootstrap_backup_form_settings() }}
{% set method = method|upper %}
{% if method in ["GET", "POST"] %}
{% set form_method = method %}
{% else %}
{% set form_method = "POST" %}
{% endif %}
{% if style is defined %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-' ~ style)|trim }) %}
{{ bootstrap_set_style(style) }}
{% endif %}
{% if form.vars.errors|length > 0 %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' has-global-errors')|trim }) %}
{% endif %}
{% if col_size is defined %}
{{ bootstrap_set_col_size(col_size) }}
{% endif %}
{% if widget_col is defined %}
{{ bootstrap_set_widget_col(widget_col) }}
{% endif %}
{% if label_col is defined %}
{{ bootstrap_set_label_col(label_col) }}
{% endif %}
{% if simple_col is defined %}
{{ bootstrap_set_simple_col(simple_col) }}
{% endif %}
{% if attr.role is not defined or attr.role is empty %}
{% set attr = attr|merge({ 'role': 'form' }) %}
{% endif %}
<form name="{{ form.vars.name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{% if form_method != method %}
<input type="hidden" name="_method" value="{{ method }}" />
{% endif %}
{% endspaceless %}
{% endblock form_start %}
{% block form_end %}
{% spaceless %}
{% if not render_rest is defined or render_rest %}
{{ form_rest(form) }}
{% endif %}
</form>
{% if bootstrap_get_style() %}
{{ bootstrap_set_style('') }}
{% endif %}
{% if bootstrap_get_col_size() %}
{{ bootstrap_set_col_size('lg') }}
{% endif %}
{% if bootstrap_get_widget_col() %}
{{ bootstrap_set_widget_col(10) }}
{% endif %}
{% if bootstrap_get_label_col() %}
{{ bootstrap_set_label_col(2) }}
{% endif %}
{% if bootstrap_get_simple_col() %}
{{ bootstrap_set_simple_col(false) }}
{% endif %}
{{ bootstrap_restore_form_settings() }}
{% endspaceless %}
{% endblock form_end %}
{% block form_enctype %}
{% spaceless %}
{% if multipart %}enctype="multipart/form-data"{% endif %}
{% endspaceless %}
{% endblock form_enctype %}
{% block global_form_errors %}
{% if errors|length > 0 %}
{% set global_errors = true %}
{{ block('form_errors') }}
{% endif %}
{% endblock global_form_errors %}
{% block form_errors %}
{% spaceless %}
{% set global_errors = global_errors|default(false) %}
{% set style = style|default(bootstrap_get_style()) %}
{% if attr.style is defined and attr.style is not empty %}
{% set style = attr.style %}
{% endif %}
{% if errors|length > 0 %}
{% if global_errors %}
<div class="alert alert-danger">
{% endif %}
<ul{% if not global_errors %} class="help-block"{% endif %}>
{% for error in errors %}
<li>{{ error.message |trans({}, translation_domain)|raw }}</li>
{% endfor %}
</ul>
{% if global_errors == true %}
</div>
{% endif %}
{% endif %}
{% endspaceless %}
{% endblock form_errors %}
{% block form_rest %}
{% spaceless %}
{% for child in form %}
{% if not child.rendered %}
{{ form_row(child) }}
{% endif %}
{% endfor %}
{% endspaceless %}
{% endblock form_rest %}
{# Support #}
{% block form_rows %}
{% spaceless %}
{% for child in form %}
{% set childAttr = {} %}
{% if attr.col_size is defined %}
{% set childAttr = childAttr|merge({ 'col_size': attr.col_size }) %}
{% endif %}
{% if attr.widget_col is defined %}
{% set childAttr = childAttr|merge({ 'widget_col': attr.widget_col }) %}
{% endif %}
{% if attr.label_col is defined %}
{% set childAttr = childAttr|merge({ 'label_col': attr.label_col }) %}
{% endif %}
{% if attr.simple_col is defined %}
{% set childAttr = childAttr|merge({ 'simple_col': attr.simple_col }) %}
{% endif %}
{% if attr.style is defined %}
{% set childAttr = childAttr|merge({ 'style': attr.style }) %}
{% endif %}
{{ form_row(child, childAttr) }}
{% endfor %}
{% endspaceless %}
{% endblock form_rows %}
{% block widget_attributes %}
{% spaceless %}
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 %}
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% elseif attrname in ['input_group'] %}{% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}
{% block widget_container_attributes %}
{% spaceless %}
{% if attr.style is defined and (attr.style == 'inline' or attr.style == 'horizontal') %}
{% set attr = attr|merge({ 'class': ('form-'~attr.style~' '~attr.class|default(''))|trim }) %}
{% set attr = attr|merge({ 'style': null }) %}
{% endif %}
{% if id is not empty %}id="{{ id }}" {% endif %}
{% for attrname, attrvalue in attr %}{% if attrvalue is not null and (attrvalue is not iterable) %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_container_attributes %}
{% block button_attributes -%}
id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif %}
{%- for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}
{% endblock button_attributes %}