XoopsFormCheckBox
1
// Display checkbox, initially checked.
2
$checked_value = 1;
3
$checkbox1 = new XoopsFormCheckBox(, 'box1', $checked_value);
4
$checkbox1->addOption($checked_value, _MD_MODNAME_CHECK_ME);
5
$form->addElement($checkbox1);
6
​
7
​
8
// Display checkbox, initially unchecked.
9
$checked_value = 1;
10
$checkbox2 = new XoopsFormCheckBox(, 'box2', !$checked_value);
11
$checkbox2->addOption($checked_value, _MD_MODNAME_CHECK_ME);
12
$form->addElement($checkbox2);
Copied!
Assuming the form's method is POST:
If box 1 is checked, the submitted form will have $_POST['box1'] = 1. Otherwise $_POST['box1'] will be undefined.
If box 2 is checked, the submitted form will have $_POST['box2'] = 1. Otherwise $_POST['box2'] will be undefined.
Last modified 1mo ago
Copy link