yes_no() table()

Show a 0 / 1 field as a disabled Yes or No button.

table()->yes_no($name = '', $extra = [])

Options

OptionMeaning
(common options)The common column options.

Example

Name Public
Newsletter Yes
Staff notes No

Code

$rows = [
    1 => ['id' => 1, 'name' => 'Newsletter', 'is_public' => 1],
    2 => ['id' => 2, 'name' => 'Staff notes', 'is_public' => 0],
];
return table($rows, ['no_pages' => 1])
    ->text('name')
    ->yes_no('is_public', ['desc' => 'Public']);

Notes

  • The labels come from the pair_yes_no data handler, translated.

Bootstrap 3 and 5

Bootstrap 5 gets its own button classes for the pair.

See also: table/allow_deny, table/btn_active, form/active_box