From f9cec3a7d219fae5084f8a2177fe3cb59f44516c Mon Sep 17 00:00:00 2001 From: buggyj Date: Tue, 19 Mar 2024 19:08:05 +0100 Subject: [PATCH 1/4] Fixes #8092 SelectWidget does not work with multiple options organised into group --- core/modules/widgets/select.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/widgets/select.js b/core/modules/widgets/select.js index 2940e3be0..381c12f41 100644 --- a/core/modules/widgets/select.js +++ b/core/modules/widgets/select.js @@ -122,8 +122,17 @@ SelectWidget.prototype.setSelectValue = function() { value = value === undefined ? "" : value; var select = this.getSelectDomNode(); var values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); + var child; for(var i=0; i < select.children.length; i++){ - select.children[i].selected = values.indexOf(select.children[i].value) !== -1 + child=select.children[i]; + if (child.children.length === 0){ + child.selected = values.indexOf(child.value) !== -1 + } else { + // grouped options + for(var y=0; y < child.children.length; y++){ + child.children[y].selected = values.indexOf(child.children[y].value) !== -1 + } + } } } else { var domNode = this.getSelectDomNode(); From eda1a510c5c18009e04bc6ea0352dedaec7b0281 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Wed, 29 Oct 2025 22:16:49 +0100 Subject: [PATCH 2/4] Consolidate variables --- core/modules/widgets/select.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/select.js b/core/modules/widgets/select.js index 381c12f41..ca9b14d92 100644 --- a/core/modules/widgets/select.js +++ b/core/modules/widgets/select.js @@ -121,8 +121,8 @@ SelectWidget.prototype.setSelectValue = function() { if (this.selectMultiple) { value = value === undefined ? "" : value; var select = this.getSelectDomNode(); - var values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); - var child; +var child, + values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); for(var i=0; i < select.children.length; i++){ child=select.children[i]; if (child.children.length === 0){ From eaa4525cc3be580c1bc553e76a142d657cf07705 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Wed, 29 Oct 2025 22:17:13 +0100 Subject: [PATCH 3/4] Apply suggestion from @saqimtiaz --- core/modules/widgets/select.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/select.js b/core/modules/widgets/select.js index ca9b14d92..13e7e4c17 100644 --- a/core/modules/widgets/select.js +++ b/core/modules/widgets/select.js @@ -121,8 +121,8 @@ SelectWidget.prototype.setSelectValue = function() { if (this.selectMultiple) { value = value === undefined ? "" : value; var select = this.getSelectDomNode(); -var child, - values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); + var child, + values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); for(var i=0; i < select.children.length; i++){ child=select.children[i]; if (child.children.length === 0){ From 92c92f303e687ddb1d0ddc6f55772ffe45cb7b33 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Tue, 20 Jan 2026 11:33:41 +0100 Subject: [PATCH 4/4] Update core/modules/widgets/select.js Co-authored-by: Mario Pietsch --- core/modules/widgets/select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/widgets/select.js b/core/modules/widgets/select.js index 13e7e4c17..ef7f36119 100644 --- a/core/modules/widgets/select.js +++ b/core/modules/widgets/select.js @@ -125,7 +125,7 @@ SelectWidget.prototype.setSelectValue = function() { values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value); for(var i=0; i < select.children.length; i++){ child=select.children[i]; - if (child.children.length === 0){ + if(child.children.length === 0){ child.selected = values.indexOf(child.value) !== -1 } else { // grouped options