Fix AutoConnectCheckbox value missing.

pull/41/head
Hieromon Ikasamo 6 years ago
parent c8d5c0b4e9
commit 23c5e21df8
  1. 19
      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) {
// Overwrite the value of all cataloged AutoConnectElements with
// arguments inherited from the last http request.
// Relies on AutoConnectRadio, it restores to false at the being
// because the checkbox argument will not pass if it is not checked.
if (elm.typeOf() == AC_Checkbox)
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); String elmValue = webServer->arg(n);
AutoConnectElement* elm = getElement(webServer->argName(n)); if (elm.typeOf() == AC_Checkbox)
if (elm) {
if (elm->typeOf() == AC_Checkbox)
elmValue = "checked"; elmValue = "checked";
setElementValue(webServer->argName(n), elmValue); setElementValue(elm.name, elmValue);
}
} }
} }
} }

Loading…
Cancel
Save