Ver código fonte

Fix saving with unset dynamic GPIO defaults

SybexXx 3 dias atrás
pai
commit
d040776419
1 arquivos alterados com 6 adições e 1 exclusões
  1. 6 1
      sd-card/html/edit_config_template.html

+ 6 - 1
sd-card/html/edit_config_template.html

@@ -2900,7 +2900,12 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _number = -1)
                 element.checked = _param[_cat][_name]["value"+j] == "true";
                 element.checked = _param[_cat][_name]["value"+j] == "true";
             }
             }
             else {
             else {
-                element.value = _param[_cat][_name]["value"+j];
+                // Keep the control's initial/default value if the config has no
+                // stored value for this parameter (e.g. a new dynamic GPIO channel).
+                var storedValue = _param[_cat][_name]["value"+j];
+                if (typeof storedValue !== "undefined" && storedValue !== null) {
+                    element.value = storedValue;
+                }
             }
             }
         }	
         }	
     }
     }