Fix AutoConnectCheckbox value missing.

pull/41/head
Hieromon Ikasamo 6 years ago
parent c8d5c0b4e9
commit 23c5e21df8
  1. 23
      src/AutoConnectAux.cpp

@ -349,13 +349,22 @@ PageElement* AutoConnectAux::_setupPage(String uri) {
* @param webServer A pointer to the class object of WebServerClass * @param webServer A pointer to the class object of WebServerClass
*/ */
void AutoConnectAux::_storeElements(WebServerClass* webServer) { void AutoConnectAux::_storeElements(WebServerClass* webServer) {
for (uint8_t n = 0; n < webServer->args(); n++) { for (AutoConnectElement& elm : _addonElm) {
String elmValue = webServer->arg(n); // Overwrite the value of all cataloged AutoConnectElements with
AutoConnectElement* elm = getElement(webServer->argName(n)); // arguments inherited from the last http request.
if (elm) { // Relies on AutoConnectRadio, it restores to false at the being
if (elm->typeOf() == AC_Checkbox) // because the checkbox argument will not pass if it is not checked.
elmValue = "checked"; if (elm.typeOf() == AC_Checkbox)
setElementValue(webServer->argName(n), elmValue); reinterpret_cast<AutoConnectCheckbox&>(elm).checked = false;
// Seek by argument, store the value to its element.
for (int8_t n = 0; n < static_cast<int8_t>(webServer->args()); n++) {
if (webServer->argName(n).equalsIgnoreCase(elm.name)) {
String elmValue = webServer->arg(n);
if (elm.typeOf() == AC_Checkbox)
elmValue = "checked";
setElementValue(elm.name, elmValue);
}
} }
} }
} }

Loading…
Cancel
Save