InputfieldCheckbox::checked() method

Get or set current checkbox boolean attribute state

Available since version 3.0.133.

Example

// the following two lines are equivalent to GET checkbox state
$checked = $f->checked();
$checked = !empty($f->attr('checked'));

// the following two lines are equivalent to SET checkbox state
$f->checked(true);
$f->attr('checked', 'checked'); 

Usage

// basic usage
$bool = $inputfieldCheckbox->checked();

// usage with all arguments
$bool = $inputfieldCheckbox->checked($checked = null);

Arguments

NameType(s)Description
checked (optional)

Return value

bool


InputfieldCheckbox methods and properties

API reference based on ProcessWire core version 3.0.244

Latest news

  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer