-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advanced Example: Impossible to align radio buttons correctly? #1158
Comments
OK I found the global css description in the strings_en.h file and the issue is because all inputfields are set to width 100% Adding folliwing inline style to the radio buttons gives a statisfying result for me: Working example :
|
Thanks, I have not had a chance to look into this at all |
Please add screenshots |
Give this a try ( you will still need to add a break before your input, as it will be inline still ) |
Hey, how do i get the return value from the radio button? when i used strcpy(retval, custom_radiobtn.getValue()); it threw a stack trace exception. @wimmatthijs |
hmm, maybe make sure its a string first? I will test, but it should be the same as other params.. |
Are you sure you are still in the same scope as WM ? |
Yeah. I try to retrieve the value in the setup itself. |
Every other parameter type seems to work perfectly. Radio button's Value is returned as null when i directly print it in serial using Serial.print(custom_radiobtn.getValue()); |
WM: Handle root --------------- CUT HERE FOR EXCEPTION DECODER --------------- Exception (28):
ctx: cont --------------- CUT HERE FOR EXCEPTION DECODER --------------- ets Jan 8 2013,rst cause:2, boot mode:(3,6) |
ok then there is a memory bounds or pointer issue there |
getValue(); doesnt work for radio buttons, this only works for standardinput fields i believe. You should be using this method to get any value from the checkbox :
not sure if that solved the issue? FYI : i'm running checkboxes now and not radiobuttons so i don't have a functioning example at the moment |
You are using a customhtml param which means it has no id and and no getvalue available, this probably can be fixed to prevent crashes, not sure why its doing that yet( havent looked ) You can use the above method and check args your self, or add a param child class to do it, add your own getValue OR use 2 inputs, but the name is an issue, i you remove it from the template ( not sure its needed as of now name = id and is aliases, I think some elements and some browsers might need name to be id instead or send forms HTTP envs as name ? I am working on this atm, reworking some of the html a little bit |
@johnnysamuael |
I would have to see the code or a min version |
I took one of the WiFiManager examples and modified with the above code from @wimmatthijs, thought I should share it here: #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
WiFiManager wm;
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40);
const char* config_str = "<p>Please select circuit configuration:</p>"
"<input style='width: auto; margin: 0 10px 0 10px;' type='radio' id='choice1' name='config_selection' value='STD' checked='checked' ><label for='choice1'>Standard</label><br>"
"<input style='width: auto; margin: 0 10px 0 10px;' type='radio' id='choice2' name='config_selection' value='GS'><label for='choice2'>Ground Station</label><br>"
"<input style='width: auto; margin: 0 10px 0 10px;' type='radio' id='choice3' name='config_selection' value='FS'><label for='choice3'>Flight Station</label><br>"
"<input style='width: auto; margin: 0 10px 0 10px;' type='radio' id='choice4' name='config_selection' value='RELAY'><label for='choice4'>LoRa Relay</label><br>";
WiFiManagerParameter config_field(config_str);
void setup() {
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
// put your setup code here, to run once:
Serial.begin(115200);
//reset settings - wipe credentials for testing
wm.resetSettings();
wm.addParameter(&custom_mqtt_server);
wm.addParameter(&config_field);
wm.setConfigPortalBlocking(false);
wm.setSaveParamsCallback(saveParamsCallback);
//automatically connect using saved credentials if they exist
//If connection fails it starts an access point with the specified name
if (wm.autoConnect("AutoConnectAP")) {
Serial.println("connected...yeey :)");
}
else {
Serial.println("Configportal running");
}
}
void loop() {
wm.process();
// put your main code here, to run repeatedly:
}
void saveParamsCallback () {
Serial.println("Get Params:");
Serial.print(custom_mqtt_server.getID());
Serial.print(" : ");
Serial.println(custom_mqtt_server.getValue());
Serial.print("Configuration Selected: ");
Serial.println(getParam("config_selection"));
}
String getParam(String name) {
//read parameter from server, for customhmtl input
String value;
if (wm.server->hasArg(name)) {
value = wm.server->arg(name);
}
return value;
} |
Thanks, yeah i was working on adding to the css for this and no idea what happened or if I even saved the code.. |
In the advanced example radio buttons are used with HTML injection.
It seems to be impossible to get the labels and the radioboxes well alligned?
I've tried in-line css but to no avail, the alignement of the radiobuttons stays central, even with or without the label.
Anybody know where to look for in order to get this working properly?
Where is the CSS used in this project?
If i find more time i will investigate further, but i hope maybe somebody has seen this issue before?
thanks,
The text was updated successfully, but these errors were encountered: