Almost all methods in a Fieldtype are primarily of concern to module developers, as Fieldtype modules do not
have a public API (most of the time). Instead, they provide methods used by Page and Field objects (and related)
to work with the field data. Most Fieldtype modules only need to implement a few methods like
Fieldtype::sanitizeValue() (which is required) and Fieldtype::getDatabaseSchema(), as the default implementation
of most other methods provided in this Fieldtype class accounts for most situations already.
There are 25 Fieldtype types in the core, plus many more Fieldtype modules in our directory.
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: WireData and Wire.
Loading
| Name | Return | Summary | |
|---|---|---|---|
Fieldtype::getBlankValue($page, Field $field) | string int object null | Return the blank value for this fieldtype, whether that is a blank string, zero value, blank object or array | |
Fieldtype::getLoadQuery(Field $field, DatabaseQuerySelect $query) | DatabaseQuerySelect | Return the query used for loading all parts of the data from this field. | |
Fieldtype::getLoadQueryAutojoin(Field $field, DatabaseQuerySelect $query) | DatabaseQuerySelect null | Return the query used for Autojoining this field (if different from getLoadQuery) or NULL if autojoin not allowed. | |
Fieldtype::loadPageField(Page $page, Field $field) | mixed null | Load the given page field from the database table and return the value. | |
Fieldtype::loadPageFieldFilter(Page $page, Field $field, $selector) | mixed null | Load the given page field from the database table and return a filtered value. | |
Fieldtype::sanitizeValue(Page $page, Field $field, $value) | string int WireArray object | Sanitize the value for runtime storage and return it. | |
Fieldtype::wakeupValue(Page $page, Field $field, $value) | string int array object | Given a raw value (value as stored in database), return the value as it would appear in a Page object. |
Additional methods and properties
In addition to the methods and properties above, Fieldtype also inherits the methods and properties of these classes:
Core Fieldtype types
| Type | Summary |
|---|---|
| FieldtypeCheckbox | This Fieldtype stores an ON/OFF toggle via a single checkbox. The ON value is 1 and OFF value is 0. |
| FieldtypeComments | Field that stores user posted comments for a single Page |
| FieldtypeDatetime | Field that stores a date and optionally time |
| FieldtypeEmail | Field that stores an e-mail address |
| FieldtypeFieldsetClose | Close a fieldset opened by FieldsetOpen. |
| FieldtypeFieldsetOpen | Open a fieldset to group fields. Should be followed by a Fieldset (Close) after one or more fields. |
| FieldtypeFieldsetTabOpen | Open a fieldset to group fields. Same as Fieldset (Open) except that it displays in a tab instead. |
| FieldtypeFile | Field that stores one or more files |
| FieldtypeFloat | Field that stores a floating point number |
| FieldtypeImage | Field that stores one or more GIF, JPG, or PNG images |
| FieldtypeInteger | Field that stores an integer |
| FieldtypeModule | Field that stores a reference to another module |
| FieldtypeOptions | Field that stores single and multi select options. |
| FieldtypePage | Field that stores one or more references to ProcessWire pages |
| FieldtypePageTitle | Field that stores a page title |
| FieldtypePassword | Field that stores a hashed and salted password |
| FieldtypeRepeater | Maintains a collection of fields that are repeated for any number of times. |
| FieldtypeText | Field that stores a single line of text |
| FieldtypeTextarea | Field that stores multiple lines of text |
| FieldtypeToggle | Configurable yes/no, on/off toggle alternative to a checkbox, plus optional “other” option. |
| FieldtypeURL | Field that stores a URL |
API reference based on ProcessWire core version 3.0.255