[GH-ISSUE #629] Can Add boolean parameters! #526

Open
opened 2026-02-28 01:25:43 +03:00 by kerem · 3 comments
Owner

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

WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "label", mqtt_server, 40);
wifiManager.addParameter(&custom_mqtt_server);
WiFiManagerParameter custom_dht22_param("dht22", "dht22 on", "radio_button", dht22, 20);
wifiManager.addParameter(&custom_dht22_param);
WiFiManagerParameter custom_ds18b20_param("ds18b20", "ds18b20 on", "radio_button", ds18b20, 20);
wifiManager.addParameter(&custom_ds18b20_param)

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?

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 ``` WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "label", mqtt_server, 40); wifiManager.addParameter(&custom_mqtt_server); WiFiManagerParameter custom_dht22_param("dht22", "dht22 on", "radio_button", dht22, 20); wifiManager.addParameter(&custom_dht22_param); WiFiManagerParameter custom_ds18b20_param("ds18b20", "ds18b20 on", "radio_button", ds18b20, 20); wifiManager.addParameter(&custom_ds18b20_param) ``` 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?
Author
Owner

@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}>";

<!-- gh-comment-id:399298033 --> @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}>"; --
Author
Owner

@tablatronix commented on GitHub (Jul 20, 2018):

If we can make it as easy as adding "type" then maybe

<!-- gh-comment-id:406730936 --> @tablatronix commented on GitHub (Jul 20, 2018): If we can make it as easy as adding "type" then maybe
Author
Owner

@dddhhhrrr commented on GitHub (Aug 21, 2018):

This would be really REALLY useful, is there any plan on adding something like this?

<!-- gh-comment-id:414537658 --> @dddhhhrrr commented on GitHub (Aug 21, 2018): This would be really REALLY useful, is there any plan on adding something like this?
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#526
No description provided.