Handbook
CheckboxCheckboxes are simple input fields with a box you can check on or off. Here's how you do a basic checkbox:
[form]
[check color 'red'] Red [submit]
[form]
[check color 'red'] Red [submit]
[form]
Here the field is color. If the box is checked, the value submitted is 'red', if not, no value is returned.
You can control whether the box is checked initially by setting checked to true or to the default value. Notice the following examples:
[form]
[check color1 'red' checked=true] Red
[check color2 'blue' checked=false] Blue
[check color3 'green' checked=green] Green
[check color4 'yellow' checked=green] Yellow [submit]
[form]
[check color1 'red' checked=true] Red
[check color2 'blue' checked=false] Blue
[check color3 'green' checked=green] Green
[check color4 'yellow' checked=green] Yellow [submit]
[form]
If you want retrieve a saved value to create a more dynamic effect, set checked to some data or info var, and if it matches the default value or is set to true, the box will check. If not it won't. You can also wrap the entire checked=true parameter inside complex conditionals to create even more dynamic effects.
Normally each check box has a unique field name, but it is possible to use multiple check boxes with the same name to create a csv (comma separated) list of values. To do this, simply add [] to the pagename. Otherwise, the last checked value will overwrite all preceding values. Notice the following example:
{?color}
[form]
[check color[] 'red' [if inlist red {?color}]checked=true[if]] Red
[check color[] 'blue' [if inlist blue {?color}]checked=true[if]] Blue
[check color[] 'green' [if inlist green {?color}]checked=true[if]] Green [submit]
[form]
[form]
[check color[] 'red' [if inlist red {?color}]checked=true[if]] Red
[check color[] 'blue' [if inlist blue {?color}]checked=true[if]] Blue
[check color[] 'green' [if inlist green {?color}]checked=true[if]] Green [submit]
[form]
This approach is very useful, especially when combined with BoltWire's powerful built in list handling capabilities. For information read the list tutorial. Note that this example also uses a slightly more complicated way to determine whether or not to pre-check a box.
Additional Parameters
Other than required, there are no useful BoltWire parameters for this input type, as the value is preset by the form creator.The required parameter conflicts with the HTML5 parameter, which is allowed. That is, if you set required=true, HTML5 browsers will block form submission--before BoltWire has a chance to. Older browsers will not recognize the parameter and ignore it, allowing BoltWire's check to kick in. If you want to rely fully on BoltWire so all users have the same experience, you can reset the HTML parameters allowed in config.php to not include "required". You can see the default value in variables.php.
By default the following html parameters are allowed:
name, value, size, maxlength, class, id, style, disabled, autofocus, required
To override the default message created when a form fails some input check, set msg to the value you wish, or set it to false to turn it off.
For information about how to insert javascript into a form element, please see that tutorial.