From e9b7c0b721cc96fcc4b0efddcb4119b4fa26802a Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 4 Jan 2024 22:55:06 +0000 Subject: [PATCH] JENKINS-72505 f:validateButton finds selected radio button --- .../java/lib/form/ValidateButtonTest.java | 5 ++++- .../TestValidateIsCalled/index.jelly | 22 ++++++++++++++++++- .../main/webapp/scripts/hudson-behavior.js | 7 +++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/test/src/test/java/lib/form/ValidateButtonTest.java b/test/src/test/java/lib/form/ValidateButtonTest.java index ac092e145285..da9bc286be14 100644 --- a/test/src/test/java/lib/form/ValidateButtonTest.java +++ b/test/src/test/java/lib/form/ValidateButtonTest.java @@ -109,13 +109,16 @@ public static final class DescriptorImpl extends Descriptore2 - + + + + + + + + + + + + + + + + + + + + + diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 678260fdad17..3be3a4fddadb 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -2708,8 +2708,13 @@ function validateButton(checkUrl, paramList, button) { paramList.split(",").forEach(function (name) { var p = findPreviousFormItem(button, name); if (p != null) { - if (p.type == "checkbox") { + if (p.type === "checkbox") { parameters[name] = p.checked; + } else if (p.type === "radio") { + while (p && !p.checked) { + p = findPreviousFormItem(p, name); + } + parameters[name] = p.value; } else { parameters[name] = p.value; }