-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathform_admin_fields.html.twig
More file actions
695 lines (621 loc) · 30.4 KB
/
form_admin_fields.html.twig
File metadata and controls
695 lines (621 loc) · 30.4 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
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'form_div_layout.html.twig' %}
{% block form_errors -%}
{% if errors|length > 0 %}
{% if not form.parent %}<div class="alert alert-danger">{% endif %}
<ul class="list-unstyled">
{% for error in errors %}
<li><i class="fas fa-exclamation-circle" aria-hidden="true"></i> {{ error.message }}</li>
{% endfor %}
</ul>
{% if not form.parent %}</div>{% endif %}
{% endif %}
{%- endblock form_errors %}
{% block form_help -%}
{% if sonata_admin_translation_domain is defined and translation_domain is null %}
{% set translation_domain = sonata_admin_translation_domain %}
{% endif %}
{% if help is not empty %}
{% set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-block sonata-ba-field-help')}) %}
{{ parent() }}
{% endif %}
{%- endblock form_help %}
{% block form_widget_simple %}
{% set type = type|default('text') %}
{% if type != 'file' %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
{% endif %}
{{ parent() }}
{% endblock form_widget_simple %}
{% block textarea_widget %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
{{ parent() }}
{% endblock textarea_widget %}
{% block money_widget -%}
{% if money_pattern == '{{ widget }}' %}
{{- block('form_widget_simple') -}}
{% else %}
{% set currencySymbol = money_pattern|replace({'{{ widget }}': ''})|trim %}
{% if money_pattern matches '/^{{ widget }}/' %}
<div class="input-group">
{{- block('form_widget_simple') -}}
<span class="input-group-addon">{{ currencySymbol }}</span>
</div>
{% elseif money_pattern matches '/{{ widget }}$/' %}
<div class="input-group">
<span class="input-group-addon">{{ currencySymbol }}</span>
{{- block('form_widget_simple') -}}
</div>
{% endif %}
{% endif %}
{%- endblock money_widget %}
{% block percent_widget %}
{% set type = type|default('text') %}
<div class="input-group">
{{ block('form_widget_simple') }}
<span class="input-group-addon">%</span>
</div>
{% endblock percent_widget %}
{% block checkbox_widget -%}
{% set parent_label_class = parent_label_class|default('') -%}
{% 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 -%}
<div class="radio">
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{%- endif %}
{%- endblock radio_widget %}
{# Labels #}
{% block form_label %}
{% if label is not same as(false) and sonata_admin.options['form_type'] == 'horizontal' %}
{% set label_class = 'col-sm-3' %}
{% endif %}
{% set label_class = label_class|default('') ~ ' control-label' %}
{% if label is not same as(false) %}
{% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ ' ' ~ label_class }) %}
{% 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 %}
{%- 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 %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{%- if translation_domain is same as(false) -%}
{{- label -}}
{%- elseif not sonata_admin.admin -%}
{{- label|trans(label_translation_parameters, translation_domain) -}}
{%- else -%}
{{- label|trans(label_translation_parameters, sonata_admin.field_description.translationDomain|default(sonata_admin.admin.translationDomain)) -}}
{%- endif -%}
</label>
{% endif %}
{% endblock form_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 sonata_admin.admin %}
{% set translation_domain = sonata_admin.field_description.translationDomain %}
{% endif %}
{# Do not display the label if widget is not defined in order to prevent double label rendering #}
{% if widget is defined %}
{% if required %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|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 not same as(false) and label is empty %}
{% set label = name|humanize %}
{% endif %}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{- widget|raw -}}
{%- if label is not same as(false) -%}
<span class="control-label__text">
{% if translation_domain is same as(false) %}
{{- label -}}
{% else %}
{{- label|trans(label_translation_parameters, translation_domain) -}}
{%- endif -%}
</span>
{%- endif -%}
</label>
{% endif %}
{% endblock checkbox_radio_label %}
{% block choice_widget_expanded %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' list-unstyled'}) %}
<ul {{ block('widget_container_attributes') }}>
{% for child in form %}
<li>
{{ form_widget(child, {
'horizontal': false,
'horizontal_input_wrapper_class': '',
'translation_domain': choice_translation_domain
}) }} {# 'horizontal' values are needed to avoid MopaBootstrapBundle messing with the DOM #}
</li>
{% endfor %}
</ul>
{% endblock choice_widget_expanded %}
{% block choice_widget_collapsed %}
{% if required and placeholder is defined and placeholder is none %}
{% set required = false %}
{% elseif required and empty_value is defined and empty_value_in_choices is defined and empty_value is none and not empty_value_in_choices and not multiple %}
{% set required = false %}
{% endif %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
{% if (sortable is defined) and sortable and multiple %}
{{ block('sonata_type_choice_multiple_sortable') }}
{% else %}
{% set data_placeholder = placeholder %}
{% if placeholder != '' %}
{% if not sonata_admin.admin %}
{% set data_placeholder = placeholder|trans({}, translation_domain) %}
{% else %}
{% set data_placeholder = placeholder|trans({}, sonata_admin.field_description.translationDomain) %}
{% endif %}
{% endif %}
{% set use_select2 = sonata_config is defined and sonata_config.getOption('use_select2') %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}{% if placeholder is defined and placeholder is not none and use_select2 %} data-placeholder="{{ data_placeholder }}"{% endif %}>
{% if empty_value is defined and empty_value is not none %}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>
{% if empty_value != '' %}
{% if not sonata_admin.admin %}
{{- empty_value|trans({}, translation_domain) -}}
{% else %}
{{- empty_value|trans({}, sonata_admin.field_description.translationDomain) -}}
{% endif %}
{% endif %}
</option>
{% elseif placeholder is defined and placeholder is not none %}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ data_placeholder }}</option>
{% endif %}
{% if preferred_choices|length > 0 %}
{% set options = preferred_choices %}
{{ block('choice_widget_options') }}
{% if choices|length > 0 %}
<option disabled="disabled">{{ separator }}</option>
{% endif %}
{% endif %}
{% set options = choices %}
{{ block('choice_widget_options') }}
</select>
{% endif %}
{% endblock choice_widget_collapsed %}
{% block date_widget %}
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% if row is not defined or row == true %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' row' }) %}
{% endif %}
{% set input_wrapper_class = input_wrapper_class|default('col-sm-4') %}
<div {{ block('widget_container_attributes') }}>
{{ date_pattern|replace({
'{{ year }}': '<div class="'~ input_wrapper_class ~ '">' ~ form_widget(form.year) ~ '</div>',
'{{ month }}': '<div class="'~ input_wrapper_class ~ '">' ~ form_widget(form.month) ~ '</div>',
'{{ day }}': '<div class="'~ input_wrapper_class ~ '">' ~ form_widget(form.day) ~ '</div>',
})|raw }}
</div>
{% endif %}
{% endblock date_widget %}
{% block time_widget %}
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% if row is not defined or row == true %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' row' }) %}
{% endif %}
{% set input_wrapper_class = input_wrapper_class|default('col-sm-6') %}
<div {{ block('widget_container_attributes') }}>
<div class="{{ input_wrapper_class }}">
{{ form_widget(form.hour) }}
</div>
{% if with_minutes %}
<div class="{{ input_wrapper_class }}">
{{ form_widget(form.minute) }}
</div>
{% endif %}
{% if with_seconds %}
<div class="{{ input_wrapper_class }}">
{{ form_widget(form.second) }}
</div>
{% endif %}
</div>
{% endif %}
{% endblock time_widget %}
{% block datetime_widget %}
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' row' }) %}
<div {{ block('widget_container_attributes') }}>
{{ form_errors(form.date) }}
{{ form_errors(form.time) }}
{% if form.date.vars.widget == 'single_text' %}
<div class="col-sm-2">
{{ form_widget(form.date) }}
</div>
{% else %}
{{ form_widget(form.date, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }}
{% endif %}
{% if form.time.vars.widget == 'single_text' %}
<div class="col-sm-2">
{{ form_widget(form.time) }}
</div>
{% else %}
{{ form_widget(form.time, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }}
{% endif %}
</div>
{% endif %}
{% endblock datetime_widget %}
{% block form_row %}
{% set show_label = show_label ?? true %}
{% set row_id = 'sonata-ba-field-container-'~id %}
{% set row_class = (row_attr.class|default('') ~ ' form-group' ~ (errors|length > 0 ? ' has-error'))|trim %}
<div{% with {attr: row_attr|merge({id: row_id, class: row_class})} %}{{ block('attributes') }}{% endwith %}>
{% set div_class = 'sonata-ba-field' %}
{% if label is same as(false) %}
{% set div_class = div_class ~ ' sonata-collection-row-without-label' %}
{% endif %}
{% if sonata_admin is defined and sonata_admin.options['form_type'] == 'horizontal' %}
{# Add an offset if no label or is a checkbox/radio #}
{% if label is same as(false) or form.vars.checked is defined %}
{% if 'collection' in form.parent.vars.block_prefixes %}
{% set div_class = div_class ~ ' col-sm-12' %}
{% else %}
{% set div_class = div_class ~ ' col-sm-9 col-sm-offset-3' %}
{% endif %}
{% else %}
{% set div_class = div_class ~ ' col-sm-9' %}
{% endif %}
{% endif %}
{% if show_label %}
{{ form_label(form, label|default(null)) }}
{% endif %}
{% if sonata_admin is defined and sonata_admin_enabled %}
{% set div_class = div_class ~ ' sonata-ba-field-' ~ sonata_admin.edit ~ '-' ~ sonata_admin.inline %}
{% endif %}
{% if errors|length > 0 %}
{% set div_class = div_class ~ ' sonata-ba-field-error' %}
{% endif %}
<div class="{{ div_class }}">
{{ form_widget(form, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #}
{% if errors|length > 0 %}
<div class="help-block sonata-ba-field-error-messages">
{{ form_errors(form) }}
</div>
{% endif %}
{{ form_help(form) }}
</div>
</div>
{% endblock form_row %}
{% block checkbox_row -%}
{% set show_label = false %}
{{ block('form_row') }}
{%- endblock checkbox_row %}
{% block radio_row -%}
{% set show_label = false %}
{{ block('form_row') }}
{%- endblock radio_row %}
{% block sonata_type_native_collection_widget_row %}
<div class="sonata-collection-row" {{ stimulus_target('sonata-collection', 'item') }}>
{% if allow_delete %}
<div class="row">
<div class="col-xs-1">
<button type="button" class="btn btn-link sonata-collection-delete" {{ stimulus_action('sonata-collection', 'delete', 'click') }}>
<i class="fas fa-minus-circle" aria-hidden="true"></i>
</button>
</div>
<div class="col-xs-11">
{% endif %}
{{ form_row(child, { label: false }) }}
{% if allow_delete %}
</div>
</div>
{% endif %}
</div>
{% endblock sonata_type_native_collection_widget_row %}
{% block sonata_type_native_collection_widget %}
{% if prototype is defined %}
{% set child = prototype %}
{% set allow_delete_backup = allow_delete %}
{% set allow_delete = true %}
{% set attr = attr|merge({
'data-prototype': block('sonata_type_native_collection_widget_row'),
'data-prototype-name': prototype.vars.name,
'class': attr.class|default(''),
})|merge(stimulus_controller('sonata-collection').toArray()) %}
{% set allow_delete = allow_delete_backup %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{{ block('sonata_type_native_collection_widget_row') }}
{% endfor %}
{{ form_rest(form) }}
{% if allow_add %}
<button type="button" class="btn btn-link sonata-collection-add" {{ stimulus_action('sonata-collection', 'add', 'click') }}>
<i class="fas fa-plus-circle" aria-hidden="true"></i>
</button>
{% endif %}
</div>
{% endblock sonata_type_native_collection_widget %}
{% block sonata_type_immutable_array_widget %}
<div {{ block('widget_container_attributes') }}>
{% for key, child in form %}
{{ block('sonata_type_immutable_array_widget_row') }}
{% endfor %}
{{ form_rest(form) }}
</div>
{% endblock sonata_type_immutable_array_widget %}
{% block sonata_type_immutable_array_widget_row %}
<div class="form-group{% if child.vars.errors|length > 0 %} has-error{% endif %}" id="sonata-ba-field-container-{{ id }}-{{ key }}">
{{ form_label(child) }}
{% set div_class = "" %}
{% if sonata_admin.options['form_type'] == 'horizontal' %}
{% set div_class = 'col-sm-9' %}
{% endif %}
<div class="{{ div_class }} sonata-ba-field sonata-ba-field-{{ sonata_admin.edit }}-{{ sonata_admin.inline }}{% if child.vars.errors|length > 0 %} sonata-ba-field-error{% endif %}">
{{ form_widget(child, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #}
{{ form_help(child) }}
</div>
{% if child.vars.errors|length > 0 %}
<div class="help-block sonata-ba-field-error-messages">
{{ form_errors(child) }}
</div>
{% endif %}
</div>
{% endblock %}
{% block sonata_type_model_autocomplete_widget %}
{% include template %}
{% endblock sonata_type_model_autocomplete_widget %}
{% block sonata_type_choice_field_mask_widget %}
{{ block('choice_widget') }}
{# Taking the form name excluding ending field glue character #}
{% set main_form_name = id|slice(0, (id|length - name|length)-1) %}
{% if expanded %}
{% set js_selector = '#' ~ main_form_name ~ '_' ~ name ~ ' input' %}
{% set js_events = ['change', 'ifChecked'] %}
{% else %}
{% set js_selector = '#' ~ main_form_name ~ '_' ~ name %}
{% set js_events = ['change'] %}
{% endif %}
<script>
jQuery(document).ready(function() {
var allFields = {{ all_fields|json_encode|raw }},
map = {{ map|json_encode|raw }},
showMaskChoiceEl = jQuery("{{ js_selector }}");
{% for js_event in js_events %}
showMaskChoiceEl.on("{{ js_event }}", function () {
choice_field_mask_show(jQuery(this).val());
});
{% endfor %}
function choice_field_mask_show(val) {
var controlGroupIdFunc = function (field) {
// Most of fields are named with an underscore
var defaultFieldId = '#sonata-ba-field-container-{{ main_form_name }}_' + field;
// Some fields may be named with a dash (like keys of immutable array form type)
if (jQuery(defaultFieldId).length === 0) {
defaultFieldId = '#sonata-ba-field-container-{{ main_form_name }}-' + field;
}
// Some fields are rendered by form_widget (no container)
if (jQuery(defaultFieldId).length === 0) {
defaultFieldId = '#{{ main_form_name }}_' + field;
}
// catch select2 fields with inline: table option
if (jQuery(defaultFieldId).length === 0) {
defaultFieldId = '#{{ main_form_name }}_' + field + '_autocomplete_input';
}
return defaultFieldId;
};
jQuery.each(allFields, function (i, field) {
var fieldContainer = controlGroupIdFunc(field);
jQuery(fieldContainer).hide();
{% if form.parent.vars.sonata_admin.inline == 'table' %}
var td = jQuery(fieldContainer).parent();
var columnIndex = td.index();
var headerTh = $("table thead tr th:eq(" + columnIndex + ")");
td.hide();
headerTh.hide();
{% endif %}
jQuery(fieldContainer).find('[required="required"]').attr('data-required', 'required').removeAttr("required");
});
if (map[val]) {
jQuery.each(map[val], function (i, field) {
var fieldContainer = controlGroupIdFunc(field);
jQuery(fieldContainer).show();
{% if form.parent.vars.sonata_admin.inline == 'table' %}
var td = jQuery(fieldContainer).parent();
var columnIndex = td.index();
var headerTh = $("table thead tr th:eq(" + columnIndex + ")");
td.show();
headerTh.show();
{% endif %}
jQuery(fieldContainer).find('[data-required="required"]').attr("required", "required");
});
}
}
{% if value is empty %}
choice_field_mask_show(showMaskChoiceEl.val());
{% else %}
choice_field_mask_show('{{ value|e('js') }}');
{% endif %}
});
</script>
{% endblock %}
{% block sonata_type_choice_multiple_sortable %}
<input type="hidden" name="{{ full_name }}" id="{{ id }}" value="{{ value|join(',') }}" />
<script>
jQuery(document).ready(function() {
var options = {};
{% block sonata_type_model_autocomplete_select2_options_js %}{% endblock %}
Admin.setup_sortable_select2(jQuery('#{{ id }}'), {{ form.vars.choices|json_encode|raw }}, options);
});
</script>
{% endblock %}
{% block sonata_type_model_list_widget %}
<div id="field_container_{{ id }}" class="field-container">
<span id="field_widget_{{ id }}" class="field-short-description">
{% if sonata_admin.value and sonata_admin.field_description.associationadmin.urlSafeIdentifier(sonata_admin.value) is not null %}
{{ render(path('sonata_admin_short_object_information', {
'_sonata_admin': sonata_admin.field_description.associationadmin.baseCodeRoute,
'objectId': sonata_admin.field_description.associationadmin.urlSafeIdentifier(sonata_admin.value),
'uniqid': sonata_admin.field_description.associationadmin.uniqid,
'linkParameters': sonata_admin.field_description.option('link_parameters', {})
} + (
sonata_admin.field_description.associationadmin.hasRequest()
? sonata_admin.field_description.associationadmin.request.attributes.get('_route_params', {})
: {}
) + app.request.query.all|default({})
)) }}
{% elseif sonata_admin.field_description.option('placeholder', 'short_object_description_placeholder') %}
<span class="inner-field-short-description">
{{ sonata_admin.field_description.option('placeholder', 'short_object_description_placeholder')|trans({}, 'SonataAdminBundle') }}
</span>
{% endif %}
</span>
<span id="field_actions_{{ id }}" class="field-actions">
<span class="btn-group">
{% if sonata_admin.field_description.associationadmin.hasroute('list') and sonata_admin.field_description.associationadmin.hasAccess('list') and btn_list %}
<a href="{{ sonata_admin.field_description.associationadmin.generateUrl('list', {select: true}) }}"
onclick="return start_field_dialog_form_list_{{ id }}(this);"
class="btn btn-info btn-sm sonata-ba-action"
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
title="{{
btn_translation_domain|default(null) is same as(false)
? btn_list
: btn_list|trans({}, btn_translation_domain|default(btn_catalogue))
}}"
>
<i class="fas fa-list"></i>
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
{{
btn_translation_domain|default(null) is same as(false)
? btn_list
: btn_list|trans({}, btn_translation_domain|default(btn_catalogue))
}}
</a>
{% endif %}
{% if sonata_admin.field_description.associationadmin.hasroute('create')
and sonata_admin.field_description.associationadmin.hasAccess('create')
and btn_add
%}
<a href="{{ sonata_admin.field_description.associationadmin.generateUrl('create') }}"
onclick="return start_field_dialog_form_add_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
title="{{
btn_translation_domain|default(null) is same as(false)
? btn_add
: btn_add|trans({}, btn_translation_domain|default(btn_catalogue))
}}"
>
<i class="fas fa-plus-circle"></i>
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
{{
btn_translation_domain|default(null) is same as(false)
? btn_add
: btn_add|trans({}, btn_translation_domain|default(btn_catalogue))
}}
</a>
{% endif %}
{% if sonata_admin.field_description.associationadmin.hasroute('edit')
and sonata_admin.field_description.associationadmin.hasAccess('edit')
and btn_edit
%}
<a href="{{ sonata_admin.value == null ? '' : sonata_admin.field_description.associationadmin.generateUrl('edit', {
(sonata_admin.field_description.associationadmin.idParameter) : sonata_admin.field_description.associationadmin.urlSafeIdentifier(sonata_admin.value)})
}}"
onclick="return start_field_dialog_form_edit_{{ id }}(this);"
class="btn btn-warning btn-sm sonata-ba-action {% if sonata_admin.value == null %}hidden{% endif %}"
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
title="{{
btn_translation_domain|default(null) is same as(false)
? btn_edit
: btn_edit|trans({}, btn_translation_domain|default(btn_catalogue))
}}"
>
<i class="fas fa-pencil-alt"></i>
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
{{
btn_translation_domain|default(null) is same as(false)
? btn_edit
: btn_edit|trans({}, btn_translation_domain|default(btn_catalogue))
}}
</a>
{% endif %}
</span>
<span class="btn-group">
{% if btn_delete %}
<button
onclick="return remove_selected_element_{{ id }}(this);"
class="btn btn-danger btn-sm sonata-ba-action"
type="button"
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
title="{{
btn_translation_domain|default(null) is same as(false)
? btn_delete
: btn_delete|trans({}, btn_translation_domain|default(btn_catalogue))
}}"
>
<i class="fas fa-minus-circle"></i>
{# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #}
{{
btn_translation_domain|default(null) is same as(false)
? btn_delete
: btn_delete|trans({}, btn_translation_domain|default(btn_catalogue))
}}
</button>
{% endif %}
</span>
</span>
<span style="display: none" >
{# Hidden text input cannot be required, because browser will throw error "An invalid form control with name='' is not focusable" #}
{{ form_widget(form, {'required':false}) }}
</span>
<div class="modal fade" id="field_dialog_{{ id }}" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
</div>
{% include '@SonataAdmin/CRUD/Association/edit_many_script.html.twig' %}
{% endblock %}
{% block sonata_type_template_widget %}
{% include template with parameters only %}
{% endblock sonata_type_template_widget %}