active_box(), allow_deny_box(), yes_no_box() form()
Two-state radios for a 0 / 1 field: Active / Inactive, Allow / Deny, Yes / No.
form()->active_box($name = '', $desc = '', $extra = [], $replace = [])
form()->allow_deny_box($name = '', $desc = '', $extra = [], $replace = [])
form()->yes_no_box($name = '', $desc = '', $extra = [], $replace = [])Options
| Option | Meaning |
|---|---|
$name | active_box() defaults to active. |
items | Value => label instead of the pair data handler (pair_active, pair_allow_deny, pair_yes_no). |
btn_group | As toggle buttons. |
renderer | html() method that draws it (default radio_box); a filter form uses button_yes_no_box. |
v2 | allow_deny_box() / yes_no_box(): the button renderer with the label on the right. |
selected, horizontal | Checked value; in one line. |
Example
Code
return form(['active' => 1, 'is_public' => 0, 'access' => 1])
->active_box()
->yes_no_box('is_public', 'Public')
->allow_deny_box('access');Bootstrap 3 and 5
With btn_group Bootstrap 5 draws btn-check inputs and btn btn-outline-secondary btn-sm labels.
See also: table/btn_active, table/yes_no, html/button_yes_no_box