Fieldtype is a module type used to represent a type of field. All Fieldtype modules descend from this.

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.

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 / Saving / Finding / Formatting / Configuration / Creating / Deleting / Other / Common

Show “Fieldtype”             Show Arguments        


Fieldtype::getBlankValue($page, Field $field)
string, int, object or nullReturn the blank value for this fieldtype, whether that is a blank string, zero value, blank object or array
Fieldtype::getLoadQuery(Field $field, DatabaseQuerySelect $query)
DatabaseQuerySelectReturn the query used for loading all parts of the data from this field.
Fieldtype::getLoadQueryAutojoin(Field $field, DatabaseQuerySelect $query)
DatabaseQuerySelect or nullReturn the query used for Autojoining this field (if different from getLoadQuery) or NULL if autojoin not allowed.
Fieldtype::loadPageField(Page $page, Field $field)
mixed or nullLoad the given page field from the database table and return the value.
Fieldtype::loadPageFieldFilter(Page $page, Field $field, $selector)
mixed or nullLoad the given page field from the database table and return a *filtered* value.
Fieldtype::sanitizeValue(Page $page, Field $field, $value)
string, int, WireArray or objectSanitize the value for runtime storage and return it.
Fieldtype::wakeupValue(Page $page, Field $field, $value)
string, int, array or objectGiven a raw value (value as stored in database), return the value as it would appear in a Page object.


Fieldtype::replacePageField(Page $src, Page $dst, Field $field)
boolMove this field’s data from one page to another.
Fieldtype::savePageField(Page $page, Field $field)
boolSave the given field from given page to the database.
Fieldtype::sleepValue(Page $page, Field $field, $value)
string, int, float or arrayGiven an 'awake' value, as set by wakeupValue(), convert the value back to a basic type for storage in database.


Fieldtype::getMatchQuery(DatabaseQuerySelect $query, string $table, string $subfield, string $operator, mixed $value)
DatabaseQueryGet the database query that matches a Fieldtype table’s data with a given value.
Fieldtype::getSelectorInfo(Field $field)
arrayReturn array with information about what properties and operators can be used with this field.
Fieldtype::isEmptyValue(Field $field, mixed $value)
boolReturn whether the given value is considered empty or not.


Fieldtype::exportValue(Page $page, Field $field, $value)
string, float, int or arrayGiven a value, return an portable version of it as either a string, int, float or array
Fieldtype::formatValue(Page $page, Field $field, $value)
mixedFormat the given value for output and return a string of the formatted value
Fieldtype::markupValue(Page $page, Field $field)
string or MarkupFieldtypeRender a markup string of the value.


Fieldtype::exportConfigData(Field $field, array $data)
arrayExport configuration values for external consumption
Fieldtype::getCompatibleFieldtypes(Field $field)
Fieldtypes or nullGet an array of Fieldtypes that are compatible with this one
Fieldtype::getConfigAdvancedInputfields(Field $field)
InputfieldWrapperGet Inputfields for advanced settings of the Field and Fieldtype
Fieldtype::getConfigAllowContext(Field $field)
arrayReturn an array of configuration field names from that are allowed in fieldgroup/template context
Fieldtype::getConfigArray(Field $field)
arraySame as getConfigInputfields but with definition as an array instead
Fieldtype::getConfigInputfields(Field $field)
InputfieldWrapperGet any Inputfields used for configuration of this Fieldtype.
Fieldtype::importConfigData(Field $field, array $data)
arrayConvert an array of exported data to a format that will be understood internally


Fieldtype::createField(Field $field)
boolCreate a new field table in the database.
Fieldtype::getDatabaseSchema(Field $field)
arrayGet the database schema for this field


Fieldtype::deleteField(Field $field)
boolDelete the given field, which implies: drop the table used by the field.
Fieldtype::deletePageField(Page $page, Field $field)
boolDelete the given Field from the given Page.
Fieldtype::deleteTemplateField(Template $template, Field $field)
boolDelete the given Field from all pages using the given template, without loading those pages.
Fieldtype::emptyPageField(Page $page, Field $field)
boolEmpty out the DB table data for page field, but leave everything else in tact.


Fieldtype::cloneField(Field $field)
FieldReturn a cloned copy of $field
Fieldtype::get(string $key)
mixedGet a property from this Fieldtype’s data
Fieldtype::getInputfield(Page $page, Field $field)
Inputfield or nullReturn new instance of the Inputfield module associated with this Fieldtype.
(nothing)Install this Fieldtype, consistent with optional Module interface
Fieldtype::longName string Long name of Fieldtype, which is typically the module title.
Fieldtype::name string Name of Fieldtype module.
Fieldtype::shortName string Short name of Fieldtype, which excludes the "Fieldtype" prefix.
(nothing)Uninstall this Fieldtype, consistent with optional Module interface
Fieldtype::upgrade($fromVersion, $toVersion)
(nothing)Called when module version changes


Fieldtype::importValue(Page $page, Field $field, $value)
string or float or int or array or object)
Fieldtype::renamedField(Field $field, $prevName)

Additional methods and properties

In addition to the methods and properties above, Fieldtype also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.97