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

OptionMeaning
$nameactive_box() defaults to active.
itemsValue => label instead of the pair data handler (pair_active, pair_allow_deny, pair_yes_no).
btn_groupAs toggle buttons.
rendererhtml() method that draws it (default radio_box); a filter form uses button_yes_no_box.
v2allow_deny_box() / yes_no_box(): the button renderer with the label on the right.
selected, horizontalChecked 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