FieldtypeInteger
Stores a whole number
The blank/unset value is an empty string '', not 0.
int when a value is present, empty string '' when blank.
// Get
$page->int_field // int, or '' when blank
(int) $page->int_field // always int (blank becomes 0)
// Set
$page->int_field = 42;
$page->int_field = -10;
$page->int_field = ''; // clear the value
$page->save('int_field');// Exact match
$pages->find('int_field=42');
// No value
$pages->find('int_field=""');
// Comparison
$pages->find('int_field>100');
$pages->find('int_field<0');
$pages->find('int_field>=10, int_field<=100'); // rangeNote on zero vs blank: By default
0and blank""are equivalent in selectors. Enable the zeroNotEmpty field setting to make them distinct — thenfield=0matches only pages with the value 0, andfield=""matches only pages with no value.
- The blank/default value is
''(empty string), not0. - Setting
zeroNotEmpty=1makes 0 and blank distinct in selectors. - Setting
defaultValueassigns a fallback for pages with no value entered. - Compatible fieldtypes:
Fieldtype,Integer FieldtypeFloat,FieldtypeDecimal,FieldtypeText. - Database column:
int NOT NULL.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Fieldtype class also inherits all the methods and properties of: Fieldtype, WireData and Wire.
Common
Additional methods and properties
In addition to the methods and properties above, Fieldtype
API reference based on ProcessWire core version 3.0.261