check_box() html()

A bare check box with its label.

html()->check_box($name = '', $value = '', $selected = '', $add_str = '', $extra = [])

Options

OptionMeaning
$name, $value, $selectedName; posted value (default 1); checked when true.
$add_strExtra attributes string.
desc, id, class_add, switchLabel text; id; classes; a Bootstrap 5 switch.

Example

Code

return html()->check_box('agree', '1', true) . ' ' . html()->check_box(['name' => 'notify', 'desc' => 'Email me', 'switch' => 1]);

Bootstrap 3 and 5

switch is a form-check form-switch under Bootstrap 5, a plain check box under 3.

See also: form/check_box, html/multi_check_box