[PR #1662] [CLOSED] Add virtual for getValue (for override getValue) #1800

Closed
opened 2026-02-28 02:13:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tzapu/WiFiManager/pull/1662
Author: @Laxilef
Created: 10/9/2023
Status: Closed

Base: masterHead: patch-1


📝 Commits (2)

  • 1303828 Add virtual for getValue (for override getValue)
  • 4e81e70 Merge branch 'tzapu:master' into patch-1

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 WiFiManager.h (+1 -1)

📄 Description

Hi
Currently there is no way to create a dynamic checkbox. I wrote the code for this:

class CheckboxParameter : public WiFiManagerParameter {
public:
  const char* checked = "type=\"checkbox\" checked";
  const char* noChecked = "type=\"checkbox\"";
  const char* trueVal = "T";

  CheckboxParameter(const char* id, const char* label, bool value): WiFiManagerParameter("") {
    init(id, label, value ? trueVal : "0", 1, "", WFM_LABEL_BEFORE);
  }

  const char* getValue() const override {
    return trueVal;
  }

  const char* getCustomHTML() const override {
    return strcmp(WiFiManagerParameter::getValue(), trueVal) == 0 ? checked : noChecked;
  }

  bool getCheckboxValue() {
    return strcmp(WiFiManagerParameter::getValue(), trueVal) == 0 ? true : false;
  }
};

But for it to work, getValue must be overridden.

https://github.com/tzapu/WiFiManager/issues/1654
https://github.com/tzapu/WiFiManager/issues/1639
https://github.com/tzapu/WiFiManager/issues/1111


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tzapu/WiFiManager/pull/1662 **Author:** [@Laxilef](https://github.com/Laxilef) **Created:** 10/9/2023 **Status:** ❌ Closed **Base:** `master` ← **Head:** `patch-1` --- ### 📝 Commits (2) - [`1303828`](https://github.com/tzapu/WiFiManager/commit/13038282286e6be732f2987a137390545fa58649) Add virtual for getValue (for override getValue) - [`4e81e70`](https://github.com/tzapu/WiFiManager/commit/4e81e708accfeb525b1c2d6419180011b7efa127) Merge branch 'tzapu:master' into patch-1 ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `WiFiManager.h` (+1 -1) </details> ### 📄 Description Hi Currently there is no way to create a dynamic checkbox. I wrote the code for this: ```C++ class CheckboxParameter : public WiFiManagerParameter { public: const char* checked = "type=\"checkbox\" checked"; const char* noChecked = "type=\"checkbox\""; const char* trueVal = "T"; CheckboxParameter(const char* id, const char* label, bool value): WiFiManagerParameter("") { init(id, label, value ? trueVal : "0", 1, "", WFM_LABEL_BEFORE); } const char* getValue() const override { return trueVal; } const char* getCustomHTML() const override { return strcmp(WiFiManagerParameter::getValue(), trueVal) == 0 ? checked : noChecked; } bool getCheckboxValue() { return strcmp(WiFiManagerParameter::getValue(), trueVal) == 0 ? true : false; } }; ``` But for it to work, getValue must be overridden. https://github.com/tzapu/WiFiManager/issues/1654 https://github.com/tzapu/WiFiManager/issues/1639 https://github.com/tzapu/WiFiManager/issues/1111 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 02:13:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1800
No description provided.