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 WiFiManagerParameterCheckbox class. Checkboxes are declared similarly to regular parameters, but with a boolean checked value in place of maxLength:
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:
Radios are implemented with the WiFiManagerParameterRadio class. 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 a name, custom html, and labelPlacement:
Individual options are created as WiFiManagerParameterRadioOption classes. 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.
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
WiFiManagerParameterCheckbox
class. Checkboxes are declared similarly to regular parameters, but with a booleanchecked
value 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
WiFiManagerParameterRadio
class. 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
,custom
html, andlabelPlacement
:Individual options are created as
WiFiManagerParameterRadioOption
classes. 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 fortype
attribute towm_consts_en.h
andwm_consts_fr.h
HTTP_FORM_PARAM_CHECK
string, which compared toHTTP_FORM_PARAM
:type
attribute and tokenmaxlength
attributeThis PR contains no breaking changes.
Please note that this PR incorporates the necessary API changes #1773 and the HTML generation changes from #1774.