[ofbiz-framework] branch trunk updated: Reverted: reverts "Improved: Form widget "checkbox" do not persist selected value with multiple options checked (OFBIZ-12154)"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Reverted: reverts "Improved: Form widget "checkbox" do not persist selected value with multiple options checked (OFBIZ-12154)"

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 548cfa8  Reverted: reverts "Improved: Form widget "checkbox" do not persist selected value with multiple options checked (OFBIZ-12154)"
548cfa8 is described below

commit 548cfa80331f533fb93e9eaa1033c1eb12f7e178
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Tue Mar 2 14:19:38 2021 +0100

    Reverted: reverts "Improved: Form widget "checkbox" do not persist selected value with multiple options checked (OFBIZ-12154)"
   
    This reverts commit 6bfae1293a41c8d7ba1780f68678dcf3b8662236.
   
    There is an issue with checkFieldMacroRendered test
---
 .../ofbiz/widget/renderer/macro/MacroFormRenderer.java    | 15 +--------------
 .../common-theme/template/macro/HtmlFormMacroLibrary.ftl  |  2 +-
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
index 17c4997..eca47ff 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
@@ -861,16 +861,6 @@ public final class MacroFormRenderer implements FormStringRenderer {
             }
         }
         String tabindex = modelFormField.getTabindex();
-
-        List<String> currentValueList = null;
-        if (UtilValidate.isNotEmpty(currentValue)) {
-            if (currentValue.startsWith("[")) {
-                currentValueList = StringUtil.toList(currentValue);
-            } else {
-                currentValueList = UtilMisc.toList(currentValue);
-            }
-        }
-
         List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, WidgetWorker.getDelegator(context));
         items.append("[");
         for (ModelFormField.OptionValue optionValue : allOptionValues) {
@@ -880,9 +870,6 @@ public final class MacroFormRenderer implements FormStringRenderer {
             items.append("{'value':'");
             items.append(optionValue.getKey());
             items.append("', 'description':'" + encode(optionValue.getDescription(), modelFormField, context));
-            if (UtilValidate.isNotEmpty(currentValueList) && currentValueList.contains(optionValue.getKey())) {
-                items.append("', 'checked':'" + Boolean.TRUE);
-            }
             items.append("'}");
         }
         items.append("]");
@@ -899,7 +886,7 @@ public final class MacroFormRenderer implements FormStringRenderer {
         sr.append("\" conditionGroup=\"");
         sr.append(conditionGroup);
         sr.append("\" allChecked=");
-        sr.append((allChecked != null && currentValueList == null ? Boolean.toString(allChecked) : "\"\""));
+        sr.append((allChecked != null ? Boolean.toString(allChecked) : "\"\""));
         sr.append(" currentValue=\"");
         sr.append(currentValue);
         sr.append("\" name=\"");
diff --git a/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl b/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
index 22a912e..741871e 100644
--- a/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
+++ b/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
@@ -197,7 +197,7 @@ under the License.
       <input type="checkbox"<#if (item_index == 0)> id="${id}"</#if><#rt/><#if tabindex?has_content> tabindex="${tabindex}"</#if><#rt/>
         <#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/>
         <#if allChecked?has_content && allChecked> checked="checked" <#elseif allChecked?has_content && !allChecked>
-          <#elseif item.checked?has_content && item.checked?boolean> checked="checked"</#if>
+          <#elseif currentValue?has_content && currentValue==item.value> checked="checked"</#if>
           name="${name?default("")?html}" value="${item.value?default("")?html}"<#if event?has_content> ${event}="${action}"</#if>/><#rt/>
         ${item.description?default("")}
     </span>