/
fields.html.twig
782 lines (719 loc) · 32.6 KB
/
fields.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
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
{% use 'form_div_layout.html.twig' %}
{# Buttons #}
{% block button_attributes %}
{% set attr = attr|merge({class: 'btn ' ~ attr.class | default("btn-default")}) %}
{{ parent() }}
{% endblock button_attributes %}
{% block button_widget %}
{% spaceless %}
{% if label is empty %}
{%- if label_format is defined and label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>
{% if icon is not empty %}
{{ mopa_bootstrap_icon(icon, icon_inverted|default(false)) }}
{% endif %}
{{ label|trans({}, translation_domain) }}</button>
{% endspaceless %}
{% endblock button_widget %}
{% block button_row %}
{% spaceless %}
{% if button_offset is defined and button_offset is not empty %}
{% set attr = attr|merge({'for': id, 'class': button_offset }) %}
<div class="form-group">
<div {% for attrname, attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{{ form_widget(form) }}
</div>
</div>
{% else %}
<div>
{{ form_widget(form) }}
</div>
{% endif %}
{% endspaceless %}
{% endblock button_row %}
{# Widgets #}
{% block textarea_widget %}
{% set type = type|default('text') %}
{% if type != 'hidden' and ( widget_addon_prepend|default(null) is not null or widget_addon_append|default(null) is not null ) %}
<div class="input-group">
{% if widget_addon_prepend|default(null) is not null %}
{% set widget_addon = widget_addon_prepend %}
{{ block('widget_addon') }}
{% endif %}
{% endif %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' ' ~ widget_form_control_class}) %}
{{ parent() }}
{% if type != 'hidden' and ( widget_addon_prepend|default(null) is not null or widget_addon_append|default(null) is not null ) %}
{% if widget_addon_append|default(null) is not null %}
{% set widget_addon = widget_addon_append %}
{{ block('widget_addon') }}
{% endif %}
</div>
{% endif %}
{% endblock textarea_widget %}
{% block form_widget_simple %}
{% spaceless %}
{% set type = type|default('text') %}
{% if type != 'hidden' and ( widget_addon_prepend|default(null) is not null or widget_addon_append|default(null) is not null or widget_btn_prepend|default(null) is not null or widget_btn_append|default(null) is not null ) %}
<div class="input-group">
{% if widget_btn_prepend|default(null) is not null %}
{% set widget_btns = widget_btn_prepend %}
{{ block('widget_btns') }}
{% endif %}
{% if widget_addon_prepend|default(null) is not null %}
{% set widget_addon = widget_addon_prepend %}
{{ block('widget_addon') }}
{% endif %}
{% endif %}
{% if not widget_remove_btn|default(null) %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' not-removable'}) %}
{% endif %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' ' ~ widget_form_control_class)|trim}) %}
{% if static_text is same as(true) %}
<p class="form-control-static">{{ value }}</p>
{% else %}
{{ parent() }}
{% endif %}
{% if type != 'hidden' and ( widget_addon_prepend|default(null) is not null or widget_addon_append|default(null) is not null or widget_btn_prepend|default(null) is not null or widget_btn_append|default(null) is not null ) %}
{% if widget_addon_append|default(null) is not null %}
{% set widget_addon = widget_addon_append %}
{{ block('widget_addon') }}
{% endif %}
{% if widget_btn_append|default(null) is not null %}
{% set widget_btns = widget_btn_append %}
{{ block('widget_btns') }}
{% endif %}
</div>
{% endif %}
{% endspaceless %}
{% endblock form_widget_simple %}
{% block form_widget_compound %}
{% spaceless %}
{% if form.parent == null %}
{% if render_fieldset %}<fieldset>{% endif %}
{% if show_legend %}{{ block('form_legend') }}{% endif %}
{% endif %}
{% if form.vars.tabbed %}
{{ form_tabs(form) }}
<div class="tab-content">
{% endif %}
{{ block('form_rows_visible') }}
{% if form.vars.tabbed %}
</div>
{% endif %}
{{ form_rest(form) }}
{% if form.parent == null %}
{% if render_fieldset %}</fieldset>{% endif %}
{% endif %}
{% endspaceless %}
{% endblock form_widget_compound %}
{% block form_tabs %}
{% if form.vars.tabsView is defined %}
{{ form_widget(form.vars.tabsView) }}
{% endif %}
{% endblock %}
{% block tabs_widget %}
{% spaceless %}
<ul class="{{ form.vars.attr.class }}">
{% for tab in form.vars.tabs %}
{% set class = (tab.active ? 'active ' : '') ~ (tab.disabled ? 'disabled' : '') %}
<li{% if class|trim is not empty %} class="{{ class }}"{% endif %}>
<a data-toggle="tab" href="#{{ tab.id }}">
{% if tab.icon %}{{ mopa_bootstrap_icon(tab.icon) }}{% endif %}
{{ tab.label|trans({}, tab.translation_domain) }}
</a>
</li>
{% endfor %}
</ul>
{% endspaceless %}
{% endblock %}
{% block form_tab %}
{% set tab_attr = attr|merge({'class': 'tab-pane' ~ (form.vars.tab_active ? ' active' : '') ~ ' ' ~ attr.class|default(''), 'id': id}) %}
<div{% for attrname, attrvalue in tab_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ block('form_widget') }}
</div>
{% endblock %}
{% block collection_widget %}
{% spaceless %}
{% if prototype is defined %}
{% set prototype_markup = form_row(prototype) %}
{% set data_prototype_name = form.vars.form.vars.prototype.vars.name|default('__name__') %}
{% set data_prototype_label = form.vars.form.vars.prototype.vars.label|default('__name__label__') %}
{% set widget_form_group_attr = widget_form_group_attr|merge({
'data-prototype': prototype_markup,
'data-prototype-name': data_prototype_name,
'data-prototype-label': data_prototype_label
})|merge(attr) %}
{% endif %}
{# Add row by default use attr.class to change#}
{% if 'collection' in form.vars.block_prefixes and attr.class is defined %}
{% set widget_form_group_attr = widget_form_group_attr|merge({'class': widget_form_group_attr.class|default('row') ~ ' ' ~ attr.class}) %}
{% endif %}
{# collection item adds class {form_id}_form-group too #}
{% set widget_form_group_attr = widget_form_group_attr|merge({'id': 'collection' ~ id ~ '_form_group', 'class': widget_form_group_attr.class ~ ' collection-items ' ~ id ~ '_form_group'}) %}
<div {% for attrname,attrvalue in widget_form_group_attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{# Add initial prototype form #}
{% if form.vars.value|length == 0 and prototype is defined %}
{% for name in prototype_names %}
{{ prototype_markup|replace({'__name__': name})|raw }}
{% endfor %}
{% endif %}
{{ block('form_widget') }}
</div>
{% endspaceless %}
{% endblock collection_widget %}
{% block choice_widget_collapsed %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' ' ~ widget_form_control_class}) %}
{% if widget_type == 'inline-btn' %}
{{ block('choice_widget_expanded') }}
{% else %}
{{ parent() }}
{% endif %}
{% endblock choice_widget_collapsed %}
{% block choice_widget_expanded %}
{% spaceless %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default(''))}) %}
{% set label_attr = label_attr|merge({'class': (label_attr.class ~ ' ' ~ (widget_type != '' ? (multiple ? 'checkbox' : 'radio') ~ '-' ~ widget_type : ''))}) %}
{% if expanded %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' ' ~ horizontal_input_wrapper_class}) %}
{% endif %}
{% if widget_type == 'inline-btn' %}
<div class="btn-group" data-toggle="buttons">
{% endif %}
{% for child in form %}
{% if widget_type not in ['inline', 'inline-btn'] %}
<div class="{{ multiple ? 'checkbox' : 'radio' }}"
{%- if widget_type == 'inline-btn' %} class="btn-group" data-toggle="buttons"{% endif %}>
{% endif %}
{% if widget_type == 'inline-btn' %}
{% set label_attr = label_attr|default({})|merge({'class': 'btn ' ~ label_attr.class|default('')}) %}
{% endif %}
{% if child.vars.checked and widget_type == 'inline-btn' %}
{% set label_attr_copy = label_attr|default({})|merge({'class': 'active ' ~ label_attr.class|default('')}) %}
{% else %}
{% set label_attr_copy = label_attr|default({}) %}
{% endif %}
<label{% for attrname, attrvalue in label_attr_copy %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ form_widget(child, {'horizontal_label_class': horizontal_label_class, 'horizontal_input_wrapper_class': horizontal_input_wrapper_class, 'attr': {'class': attr.widget_class|default('') }}) }}
{% if widget_type == 'inline-btn' or widget_checkbox_label == 'widget'%}
{{ child.vars.label|trans({}, translation_domain)|raw }}
{% else %}
{{ child.vars.label|trans({}, translation_domain) }}
{% endif %}
</label>
{% if widget_type not in ['inline', 'inline-btn'] %}
</div>
{% endif %}
{% endfor %}
{% if widget_type == 'inline-btn' %}
</div>
{% endif %}
{% endspaceless %}
{% endblock choice_widget_expanded %}
{% block checkbox_widget %}
{% spaceless %}
{% if label is not same as(false) and label is empty %}
{%- if label_format is defined and label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
{% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes %}
<div
{%- if widget_type == 'inline-btn' %} class="btn-group" data-toggle="buttons"
{%- else %} class="checkbox"
{%- endif %}>
{% endif %}
{% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes and label_render %}
{% if widget_type == 'inline-btn' %}
{% set label_attr = attr|default({}) %}
{% if checked %}
{% set label_attr = label_attr|merge({'class': 'active ' ~ attr.class|default('')}) %}
{% endif %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}
{%- if not horizontal %} class="checkbox-inline"{% endif %}>
{% endif %}
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %}/>
{% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes %}
{% if label_render %}
{% if widget_checkbox_label in ['both', 'widget'] %}
{{ label|trans({}, translation_domain)|raw }}
{% else %}
{{ block('form_help') }}
{% endif %}
</label>
{% endif %}
{% endif %}
{% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes %}
</div>
{% endif %}
{% endspaceless %}
{% endblock checkbox_widget %}
{% block date_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{% if datepicker is defined %}
{% set widget_addon_icon = widget_addon_append.icon is defined ? widget_addon_append.icon : 'calendar' %}
<div {% if datepicker.attr is defined %}{%- for attrname, attrvalue in datepicker.attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}{% endif %} data-provider="datepicker" class="input-group date" data-date="{{ value }}" data-link-field="{{ id }}" data-link-format="yyyy-mm-dd">
<input type="hidden" value="{{ value }}" {{ block('widget_attributes') }}>
{% if widget_reset_icon is defined and widget_reset_icon == true %}
<span class="input-group-addon">{{ mopa_bootstrap_icon('remove') }}</span>
{% endif %}
{# Clear the id & name attributes so that they don't override the hidden fields values #}
{% set id = id ~ '_mopa_picker_display' %}
{% set full_name = null %}
{% set type = 'text' %}
{{ block('form_widget_simple') }}
<span class="input-group-addon">{{ mopa_bootstrap_icon(widget_addon_icon) }}</span>
</div>
{% else %}
{{ block('form_widget_simple') }}
{% endif %}
{% else %}
{% set attr = attr|merge({'class': attr.class|default('inline')}) %}
<div class="row">
{{ date_pattern|replace({
'{{ year }}': '<div class="'~date_wrapper_class['year']|default('col-xs-4')~'">'~form_widget(form.year, {'attr': {'class': attr.widget_class|default('') ~ ''}})~'</div>',
'{{ month }}': '<div class="'~date_wrapper_class['month']|default('col-xs-4')~'">'~form_widget(form.month, {'attr': {'class': attr.widget_class|default('') ~ ''}})~'</div>',
'{{ day }}': '<div class="'~date_wrapper_class['day']|default('col-xs-4')~'">'~form_widget(form.day, {'attr': {'class': attr.widget_class|default('') ~ ''}})~'</div>',
})|raw }}
</div>
{% endif %}
{% endspaceless %}
{% endblock date_widget %}
{% block time_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{% if timepicker is defined %}
{% set widget_addon_icon = widget_addon_append.icon is defined ? widget_addon_append.icon : 'time' %}
<div {% if timepicker.attr is defined %}{%- for attrname, attrvalue in timepicker.attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}{% endif %} data-provider="timepicker" class="input-group date" data-date="{{ value }}" data-link-field="{{ id }}" data-link-format="hh:ii">
<input type="hidden" value="{{ value }}" {{ block('widget_attributes') }}>
{% if widget_reset_icon is defined and widget_reset_icon == true %}
<span class="input-group-addon">{{ mopa_bootstrap_icon('remove') }}</span>
{% endif %}
{# Clear the id & name attributes so that they don't override the hidden fields values #}
{% set id = id ~ '_mopa_picker_display' %}
{% set full_name = null %}
{% set type = 'text' %}
{{ block('form_widget_simple') }}
<span class="input-group-addon">{{ mopa_bootstrap_icon(widget_addon_icon) }}</span>
</div>
{% else %}
{{ block('form_widget_simple') }}
{% endif %}
{% else %}
{% set attr = attr|merge({'class': attr.class|default('')}) %}
{% spaceless %}
{{ form_widget(form.hour, { 'horizontal_input_wrapper_class': horizontal_input_wrapper_class|default('col-sm-2')}) }}
{% if with_minutes %}
{{ form_widget(form.minute, { 'horizontal_input_wrapper_class': horizontal_input_wrapper_class|default('col-sm-2')}) }}
{% endif %}
{% if with_seconds %}
:{{ form_widget(form.second, { 'horizontal_input_wrapper_class': horizontal_input_wrapper_class|default('col-sm-2') }) }}
{% endif %}
{% endspaceless %}
{% endif %}
{% endspaceless %}
{% endblock time_widget %}
{% block datetime_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{% if datetimepicker is defined %}
{% set widget_addon_icon = widget_addon_append.icon is defined ? widget_addon_append.icon : 'th' %}
<div {% if datetimepicker.attr is defined %}{%- for attrname, attrvalue in datetimepicker.attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %}{% endif %} data-provider="datetimepicker" class="input-group date" data-date="{% if value %}{{ value|date('Y-m-d H:i') }}{% endif %}" data-link-field="{{ id }}" data-link-format="yyyy-mm-dd hh:ii">
<input type="hidden" value="{% if value %}{{ value|date('Y-m-d H:i') }}{% endif %}" {{ block('widget_attributes') }}>
{% if widget_reset_icon is defined and widget_reset_icon == true %}
<span class="input-group-addon">{{ mopa_bootstrap_icon('remove') }}</span>
{% endif %}
{# Clear the id & name attributes so that they don't override the hidden fields values #}
{% set id = id ~ '_mopa_picker_display' %}
{% set full_name = null %}
{% set type = 'text' %}
{{ block('form_widget_simple') }}
<span class="input-group-addon">{{ mopa_bootstrap_icon(widget_addon_icon) }}</span>
</div>
{% else %}
{{ block('form_widget_simple') }}
{% endif %}
{% else %}
{% set attr = attr|merge({'class': attr.class|default('')}) %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form.date) }}
{{ form_errors(form.time) }}
{{ form_widget(form.date, {'attr': {'class': attr.widget_class|default('')}, 'horizontal_input_wrapper_class': horizontal_input_wrapper_class|default('col-sm-3')}) }}
{{ form_widget(form.time, {'attr': {'class': attr.widget_class|default('')}, 'horizontal_input_wrapper_class': horizontal_input_wrapper_class|default('col-sm-2')}) }}
</div>
{% endif %}
{% endspaceless %}
{% endblock datetime_widget %}
{% block percent_widget %}
{% spaceless %}
{% set widget_addon_append = widget_addon_append|merge({'text': widget_addon_append.text|default('%')}) %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock percent_widget %}
{% block money_widget %}
{% spaceless %}
{% set widget_addon_prepend = (widget_addon_prepend != false or widget_addon_prepend == null) and money_pattern != '{{ widget }}' ? {'text': money_pattern|replace({ '{{ widget }}': ''})} : widget_addon_prepend|default(null) %}
{{ block('form_widget_simple') }}
{% endspaceless %}
{% endblock money_widget %}
{% block file_widget %}
{% spaceless %}
{% set type = type|default('file') %}
{% if widget_addon_prepend|default(null) is not null %}
{% set widget_addon = widget_addon_prepend %}
{{ block('widget_addon') }}
{% endif %}
<input type="{{ type }}" {{ block('widget_attributes') }}/>
{% if type != 'hidden' and widget_addon.type|default(null) is not null %}
{% if widget_addon_append|default(null) is not null %}
{% set widget_addon = widget_addon_append %}
{{ block('widget_addon') }}
{% endif %}
{% endif %}
{% endspaceless %}
{% endblock file_widget %}
{# Labels #}
{% block form_legend %}
{% spaceless %}
{% if label is empty %}
{%- if label_format is defined and label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
<{{ legend_tag }}>{{ label|trans({}, translation_domain) }}</{{ legend_tag }}>
{% endspaceless %}
{% endblock form_legend %}
{% block form_label %}
{% if 'checkbox' not in block_prefixes or widget_checkbox_label in ['label', 'both'] %}
{% spaceless %}
{% if label is not same as(false) %}
{% if label is empty %}
{%- if label_format is defined and label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
{% if not compound %}
{% set label_attr = label_attr|merge({'for': id}) %}
{% endif %}
{% set label_attr_class = '' %}
{% if horizontal %}
{% set label_attr_class = 'control-label ' ~ label_attr_class ~ horizontal_label_class %}
{% endif %}
{% if horizontal_label_div_class %}
<div class="{{ horizontal_label_div_class }}">
{% endif %}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ " " ~ label_attr_class ~ (required ? ' required' : ' optional'))|trim }) %}
<label{% for attrname,attrvalue in label_attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{{ label|trans({}, translation_domain) }}
{{- block('label_asterisk') }}
{% if 'collection' in form.vars.block_prefixes and widget_add_btn|default(null) and form.vars.allow_add == true %}
{{ block('form_widget_add_btn') }}
{% endif %}
{% if help_label %}
{{ block('help_label') }}
{% endif %}
{% if help_label_tooltip.title %}
{{ block('help_label_tooltip') }}
{% endif %}
{% if help_label_popover.title %}
{{ block('help_label_popover') }}
{% endif %}
</label>
{% if horizontal_label_div_class %}
</div>
{% endif %}
{% endif %}
{% endspaceless %}
{% endif %}
{% endblock form_label %}
{% block help_label %}
<span class="help-block">{{ help_label|trans({}, translation_domain) }}</span>
{% endblock help_label %}
{% block help_label_tooltip %}
<span class="help-block">
<a href="#" data-toggle="tooltip" data-placement="{{ help_label_tooltip.placement}}" data-title="{{ help_label_tooltip.title|trans({}, translation_domain) }}">
{% if help_label_tooltip.icon is not same as(false) %}
{{ mopa_bootstrap_icon(help_label_tooltip.icon) }}
{% endif %}
{% if help_label_tooltip.text is not same as(null) %}
{{ help_label_tooltip.text }}
{% endif %}
</a>
</span>
{% endblock help_label_tooltip %}
{% block help_block_tooltip %}
{% set help_label_tooltip = help_block_tooltip %}
{{ block('help_label_tooltip') }}
{% endblock help_block_tooltip %}
{% block help_label_popover %}
<span class="help-block">
<a href="#" data-toggle="popover" data-trigger="hover" data-placement="{{ help_label_popover.placement}}" data-title="{{ help_label_popover.title|trans({}, translation_domain) }}" data-content="{{ help_label_popover.content|trans({}, translation_domain) }}" data-html="true">
{% if help_label_popover.icon is not same as(false) %}
{{ mopa_bootstrap_icon(help_label_popover.icon) }}
{% endif %}
{% if help_label_popover.text is not same as(null) %}
{{ help_label_popover.text|raw }}
{% endif %}
</a>
</span>
{% endblock help_label_popover %}
{% block help_block_popover %}
{% set help_label_popover = help_block_popover %}
{{ block('help_label_popover') }}
{% endblock help_block_popover %}
{% 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 %}
{# Rows #}
{% block form_actions_row %}
{{ block('button_row') }}
{% endblock %}
{% block form_rows_visible %}
{% spaceless %}
{% if errors|length > 0 %}
<div class="symfony-form-errors">
{{ form_errors(form) }}
</div>
{% endif %}
{% for child in form %}
{% if 'hidden' not in child.vars.block_prefixes %} {# smbdy: why do we not add the hiddens of childs? 131024 phiamo: i think form rest should do this !? it was afaik removed because it cause side effekts #}
{{ form_row(child) }}
{% endif %}
{% endfor %}
{% endspaceless %}
{% endblock form_rows_visible %}
{% block form_row %}
{% spaceless %}
{% if 'tab' in form.vars.block_prefixes %}
{{ block('form_tab') }}
{% elseif embed_form is same as(true) %}
{% if widget_prefix is not empty %}{{ widget_prefix|trans({}, translation_domain)|raw }}{% endif %} {{ form_widget(form, _context) }} {% if widget_suffix is not empty %}{{ widget_suffix|trans({}, translation_domain)|raw }}{% endif %}
{% else %}
{{ block('widget_form_group_start') }}
{% if horizontal and not label_render %}
{% set horizontal_input_wrapper_class = horizontal_input_wrapper_class ~ ' ' ~ horizontal_label_offset_class %}
{% endif %}
{% if horizontal %}
<div class="{{ horizontal_input_wrapper_class }}">
{% endif %}
{% if widget_prefix is not empty %}{{ widget_prefix|trans({}, translation_domain)|raw }}{% endif %} {{ form_widget(form, _context) }} {% if widget_suffix is not empty %}{{ widget_suffix|trans({}, translation_domain)|raw }}{% endif %}
{% set type = type|default('text') %}
{% if type != 'hidden' %}
{{ block('form_message') }}
{% endif %}
{% if horizontal %}
</div>
{% endif %}
{% if form.parent is not null and 'collection' in form.parent.vars.block_prefixes and widget_remove_btn|default(null) and form.parent.vars.allow_delete|default(false) %}
{{ block('form_widget_remove_btn') }}
{% endif -%}
{{ block('widget_form_group_end') }}
{% endif %}
{% endspaceless %}
{% endblock form_row %}
{# Support #}
{% block form_message %}
{% spaceless %}
{{ form_errors(form) }}
{% if ('checkbox' not in block_prefixes or widget_checkbox_label != 'label') and help_block %}
{{ block('form_help') }}
{% endif %}
{% endspaceless %}
{% endblock form_message %}
{# Help #}
{% block form_help %}
{% spaceless %}
{% if help_block %}<p class="help-block">{{ help_block|trans({}, translation_domain)|raw }}</p>{%endif %}
{% if help_block_tooltip.title %}
{{ block('help_block_tooltip') }}
{% endif %}
{% if help_block_popover.title %}
{{ block('help_block_popover') }}
{% endif %}
{% endspaceless %}
{% endblock form_help %}
{% block form_widget_add_btn %}
{% spaceless %}
{% if widget_add_btn|default(null) %}
{% set button_type = 'add' %}
{% set button_values = widget_add_btn %}
{{ block('collection_button') }}
{% endif %}
{% endspaceless %}
{% endblock form_widget_add_btn %}
{% block form_widget_remove_btn %}
{% spaceless %}
{% if widget_remove_btn.wrapper_div is defined and widget_remove_btn.wrapper_div is not same as(false) %}
<div class="{{ widget_remove_btn.wrapper_div.class }}">
{% endif %}
{% if widget_remove_btn.horizontal_wrapper_div is defined and widget_remove_btn.horizontal_wrapper_div is not same as(false) %}
<div class="{{ widget_remove_btn.horizontal_wrapper_div.class }}">
{% endif %}
{% if widget_remove_btn|default(null) %}
{% set button_type = 'remove' %}
{% set button_values = widget_remove_btn %}
{{ block('collection_button') }}
{% endif %}
{% if widget_remove_btn.horizontal_wrapper_div is defined and widget_remove_btn.horizontal_wrapper_div is not same as(false) %}
</div>
{% endif %}
{% if widget_remove_btn.wrapper_div is defined and widget_remove_btn.wrapper_div is not same as(false) %}
</div>
{% endif %}
{% endspaceless %}
{% endblock form_widget_remove_btn %}
{% block collection_button %}
<a {% for attrname,attrvalue in button_values.attr %} {{attrname}}="{{attrvalue}}"{% endfor %} data-collection-{{ button_type }}-btn=".{{ form.vars['id'] }}_form_group">
{% if button_values.icon is not null %}
{{ mopa_bootstrap_icon(button_values.icon, button_values.icon_inverted|default(false)) }}
{% endif %}
{% if button_values.label is defined %}
{{ button_values.label|trans({}, translation_domain) }}
{% endif %}
</a>
{% endblock collection_button %}
{% block label_asterisk %}
{% if required %}
{%- if render_required_asterisk %} <span class="asterisk">*</span>{% endif %}
{% else %}
{%- if render_optional_text %} <span>{{ "(optional)"|trans({}, translation_domain) }}</span>{% endif %}
{% endif %}
{% endblock label_asterisk %}
{% block widget_addon %}
{% spaceless %}
{% set widget_addon_icon = widget_addon.icon is defined ? widget_addon.icon : null %}
{% set widget_addon_icon_inverted = widget_addon.icon_inverted is defined ? widget_addon.icon_inverted : false %}
<span class="input-group-addon">{{ (widget_addon.text|default(false) ? widget_addon.text|trans({}, translation_domain)|raw : mopa_bootstrap_icon(widget_addon_icon, widget_addon_icon_inverted)) }}</span>
{% endspaceless %}
{% endblock widget_addon %}
{% block widget_btns %}
{% spaceless %}
<span class="input-group-btn">
{% for widget_btn in widget_btns %}
<button type="{{ widget_btn.type | default('button') }}" class="{{ 'btn ' ~ widget_btn.class | default('btn-default') }}">
{% if widget_btn.icon is not empty %}
{{ mopa_bootstrap_icon(widget_btn.icon, widget_btn.icon_inverted | default(false)) }}
{% endif %}
{{ widget_btn.label | default("") | trans({}, translation_domain) }}</button>
{% endfor %}
</span>
{% endspaceless %}
{% endblock widget_btns %}
{# Errors #}
{% block form_errors %}
{% spaceless %}
{% if error_delay %}
{% for child in form %}
{% if loop.index == 1 %}
{% if child.set('errors', errors) %}{% endif %}
{% endif %}
{% endfor %}
{% else %}
{% if errors|length > 0 %}
{% if form.parent == null %}
{% from 'MopaBootstrapBundle::flash.html.twig' import flash %}
{% for error in errors %}
{{ flash('danger', error.message) }}
{% endfor %}
{% else %}
<span class="help-{{ block('error_type') }}">
{% for error in errors %}
{{ error.message }} <br>
{% endfor %}
</span>
{% endif %}
{% endif %}
{% endif %}
{% endspaceless %}
{% endblock form_errors %}
{# used to determine which type of error #}
{% block error_type %}
{% spaceless %}
{% if error_type %}
{{ error_type }}
{% elseif form.parent == null %}
{{ form.vars.error_type | default('inline') }}
{% else %}
block
{% endif %}
{% endspaceless %}
{% endblock error_type %}
{# widget helper blocks #}
{% block widget_form_group_start %}
{% if widget_form_group|default(false) or form.parent == null %}
{% if form.parent is not null and 'collection' in form.parent.vars.block_prefixes %} {# i am a collection child #}
{% if not omit_collection_item %}
{# collection item wrapper doesnt need form-group it gets added to childs anyways #}
{% set widget_form_group_attr = widget_form_group_attr|merge({class: 'collection-item'}) %}
{% endif %}
{% endif %}
{% if errors|length > 0 %}
{# Add Error Class to Widget Wrapper#}
{% set widget_form_group_attr = widget_form_group_attr|merge({'class': widget_form_group_attr.class|default('') ~ ' has-error'}) %}
{% endif %}
{% if help_widget_popover.selector is same as(null) %}
{% set help_widget_popover = help_widget_popover|merge({'selector': '#' ~ id }) %}
{% endif %}
<div{% if help_widget_popover.title is not same as(null) %}{{ block('help_widget_popover') }}{% endif %} {% for attrname,attrvalue in widget_form_group_attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{# a form item containing the field in block_prefixes is a near subform or a field directly #}
{% if (form|length > 0 and form.parent != null)
and 'field' not in form.vars.block_prefixes
and 'date' not in form.vars.block_prefixes %}
{% if show_child_legend%}
{{ block('form_legend') }}
{% elseif label_render %}
{{ form_label(form, label|default(null)) }}
{% else %}
{% endif %}
{% else %}
{% if label_render %}
{{ form_label(form, label|default(null)) }}
{% endif %}
{% endif %}
{% else %}
{% if label_render %}
{{ form_label(form, label|default(null)) }}
{% endif %}
{% endif %}
{% endblock widget_form_group_start %}
{% block help_widget_popover %}
{% spaceless %}
{% for attrname,attrvalue in help_widget_popover %}
data-{{attrname}}="{{attrvalue|trans({}, domain|default('messages'))}}"
{% endfor %}
{% endspaceless %}
{% endblock help_widget_popover %}
{% block widget_form_group_end %}
{% spaceless %}
{% if widget_form_group|default(false) or form.parent == null %}
</div>
{% endif %}
{% endspaceless %}
{% endblock widget_form_group_end %}