mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #629] Can Add boolean parameters! #526
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#526
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?
Originally created by @ideaChenGo on GitHub (Jun 22, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/629
#134
Hello
Could you make the PR to show how you solved your task?
I think that boolean parameters at the configuration portal will be useful for others. Yeas, we have an ability to add custom html and css, but it would be ok to have also the default way to make basic html objects/labels/radiobuttons/etc (like in Twitter Bootstrap).
I think, boolean parameters with radiobuttons could be look like these:
idea
And it seems to be ok to add a type of form label for custom parameters like:
// id/name, placeholder/prompt, type, default, length
Maybe it needs to make a new handler for these inputs to store data depends on element type (e.g. store boolean in json for radiobutton elements).
what do you think?
@ideaChenGo commented on GitHub (Jun 22, 2018):
fngstudios commented on 11 Aug 2017
sorry ,i begin use github,no idea @fngstudios . just copy to here.
This is what I did for the bool parameters:Added the getType method to WiFiManagerParameter and modifyed the constructor:
WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length,bool isBoolean) {
.._isBoolean = isBoolean;.
}
bool WiFiManagerParameter::getType(){return _isBoolean;}
Then when you render the parameters:
// add the extra parameters to the form
for (int i = 0; i < _paramsCount; i++) {
if (_params[i] == NULL) {break;}
if (!_params[i]->getType()){
String pitem = FPSTR(HTTP_FORM_PARAM);
pitem.replace("{i}", _params[i]->getID());
pitem.replace("{n}", _params[i]->getID());
pitem.replace("{p}", _params[i]->getPlaceholder());snprintf(parLength, 2, "%d", _params[i]->getValueLength());
pitem.replace("{l}", parLength);pitem.replace("{v}", _params[i]->getValue());page += pitem;
}else{
String pitem = FPSTR(HTTP_FORM_BOOL_PARAM);
pitem.replace("{i}", _params[i]->getID());
pitem.replace("{n}", _params[i]->getID());
pitem.replace("{p}", _params[i]->getPlaceholder());snprintf(parLength, 2, "%d", _params[i]->getValueLength());
pitem.replace("{l}", parLength);
if (_params[i]->getValue()){
pitem.replace("{c}", "checked");
}else{
pitem.replace("{c}", "");
}
page += pitem;
}}
And in the .h:
const char HTTP_FORM_BOOL_PARAM[] PROGMEM = "{p}<input type='checkbox' id='{i}' name='{n}' length='{l}' value='1' {c}>";
@tablatronix commented on GitHub (Jul 20, 2018):
If we can make it as easy as adding "type" then maybe
@dddhhhrrr commented on GitHub (Aug 21, 2018):
This would be really REALLY useful, is there any plan on adding something like this?