mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[PR #1775] WiFiManagerParameter Checkboxes and Radios #1831
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1831
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/tzapu/WiFiManager/pull/1775
Author: @dmadison
Created: 10/31/2024
Status: 🔄 Open
Base:
master← Head:params-classes📝 Commits (10+)
0df7c77Refactor parameter 'length' as 'maxLength'f75dd98Change param value length function namedd38239Change param getID to getNameb002b03Add setValueReceived function to paramsc781390Remove parameter friendship with WiFiManager2703370Add negative check to param max length246d521Make param destructor virtual944589cMove param HTML generation to classc4665fcRemove param token "I" processing5d7848fAdd checkbox parameter class📊 Changes
9 files changed (+525 additions, -90 deletions)
View changed files
📝
WiFiManager.cpp(+434 -75)📝
WiFiManager.h(+83 -12)📝
examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino(+1 -1)📝
keywords.txt(+2 -2)📝
wm_consts_en.h(+1 -0)📝
wm_consts_fr.h(+1 -0)📝
wm_strings_en.h(+1 -0)📝
wm_strings_es.h(+1 -0)📝
wm_strings_fr.h(+1 -0)📄 Description
This PR adds checkbox and radio input classes derived from
WiFiManagerParameter, allowing users to easily add those inputs to their config pages.Checkboxes
Checkboxes are implemented with the
WiFiManagerParameterCheckboxclass. Checkboxes are declared similarly to regular parameters, but with a booleancheckedvalue in place ofmaxLength:Because the library uses the parameter's 'value' to mean both 'default value' and 'current value', checkboxes implement their own value storage to indicate whether the checkbox is "checked" or not. This lets the value (string) and 'checked' state persist between server updates while requiring minimal additional storage:
Demo
Webpage
User Code
HTML
Serial Debug
Radios
Radios are implemented with the
WiFiManagerParameterRadioclass. Radios are different to regular parameters, because each radio object contains a number of individual inputs that are all collected under one parameter. Because of this radio objects are only declared with aname,customhtml, andlabelPlacement:Individual options are created as
WiFiManagerParameterRadioOptionclasses. These reference the radio object and add themselves to a vector in the radio class on construction:When the params page is submitted, the string is validated against the stored options and then stored in the class as the value. This simplifies the user-side parameter saving code, because the relevant value is provided as part of a single parameter regardless of how many options there are.
Demo
Webpage
User Code
HTML
Serial Debug
Incidental Changes
{T}token fortypeattribute towm_consts_en.handwm_consts_fr.hHTTP_FORM_PARAM_CHECKstring, which compared toHTTP_FORM_PARAM:typeattribute and tokenmaxlengthattributeThis PR contains no breaking changes.
Please note that this PR incorporates the necessary API changes #1773 and the HTML generation changes from #1774.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.