From 76f3ecda98d3989e9b6437d8b2cd2a14372f9757 Mon Sep 17 00:00:00 2001
From: David Maixner <dmaixner@gmail.com>
Date: Tue, 25 Feb 2020 19:09:57 +0100
Subject: [PATCH] Fix setElementValue for checkbox.

This is fixing the issue, when setElementValue is called on checkbox
element, which is already checked. Now it is possible to uncheck this
element.
---
 src/AutoConnectAux.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/AutoConnectAux.cpp b/src/AutoConnectAux.cpp
index 0b84f01..d1ff2ad 100644
--- a/src/AutoConnectAux.cpp
+++ b/src/AutoConnectAux.cpp
@@ -188,10 +188,14 @@ bool AutoConnectAux::setElementValue(const String& name, const String value) {
     }
     else {
       if (elm->typeOf() == AC_Checkbox) {
+        AutoConnectCheckbox* elmCheckbox = reinterpret_cast<AutoConnectCheckbox*>(elm);
         if (value == "checked") {
-          AutoConnectCheckbox* elmCheckbox = reinterpret_cast<AutoConnectCheckbox*>(elm);
           elmCheckbox->checked = true;
         }
+        else
+        {
+          elmCheckbox->checked = false;
+        }
       }
       else if (elm->typeOf() == AC_Radio) {
         AutoConnectRadio* elmRadio = reinterpret_cast<AutoConnectRadio*>(elm);