Fix select2 with allowClear and no placeholder (Z#23203145)

This commit is contained in:
Raphael Michel
2025-08-04 17:15:48 +02:00
parent 154f10af8f
commit 34b656989f

View File

@@ -533,7 +533,7 @@ var form_handlers = function (el) {
allowClear: !$s.prop("required"), allowClear: !$s.prop("required"),
width: '100%', width: '100%',
language: $("body").attr("data-select2-locale"), language: $("body").attr("data-select2-locale"),
placeholder: $(this).attr("data-placeholder"), placeholder: $(this).attr("data-placeholder") || "",
ajax: { ajax: {
url: $(this).attr('data-select2-url'), url: $(this).attr('data-select2-url'),
data: function (params) { data: function (params) {
@@ -594,7 +594,7 @@ var form_handlers = function (el) {
} }
} }
}, },
placeholder: $(this).attr("data-placeholder"), placeholder: $(this).attr("data-placeholder") | "",
templateResult: function (res) { templateResult: function (res) {
if (!res.id) { if (!res.id) {
return res.text; return res.text;