From 7487557946a19e1600469ab92443d9ec51f7b22e Mon Sep 17 00:00:00 2001 From: XingY Date: Wed, 29 Apr 2026 09:04:44 -0700 Subject: [PATCH] GitHub Issue 1076: Clearing a MVTC value in the SDMS UI is confusing --- api/src/org/labkey/api/data/DataColumn.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/src/org/labkey/api/data/DataColumn.java b/api/src/org/labkey/api/data/DataColumn.java index 2bdbffe6c73..e6f2b90a50d 100644 --- a/api/src/org/labkey/api/data/DataColumn.java +++ b/api/src/org/labkey/api/data/DataColumn.java @@ -773,6 +773,19 @@ private void renderSelectFormInput(HtmlWriter out, String formFieldName, Object out.write(select.addOptions(options)); + /* + * GitHub Issue 1076: Clearing a MVTC value in the SDMS UI is confusing + * Multi-selects are weird. If no options are selected they don't post at all, so it's impossible to tell + * the difference between values that weren't on the html form at all and ones that were cleared by the user. + * + * To fix this, each multiple-select posts a hidden field with the same name and an empty value, + * ensuring the field is always present in the POST body. + */ + if (isMultiple && !_boundColumn.isRequired()) + out.write(InputBuilder.hidden() + .name(formFieldName) + .value("")); + // disabled inputs are not posted with the form, so we output a hidden form element: if (disabledInput) renderHiddenFormInput(out, formFieldName, value);