Fieldtype class

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.

Show class?             Show args?        

Loading

NameReturnSummary 
Fieldtype::getBlankValue($page, Field $field)
string int object 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 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 nullLoad the given page field from the database table and return the value.
Fieldtype::loadPageFieldFilter(Page $page, Field $field, $selector)
mixed nullLoad the given page field from the database table and return a *filtered* value.
Fieldtype::sanitizeValue(Page $page, Field $field, $value)
string int WireArray objectSanitize the value for runtime storage and return it. 
Fieldtype::wakeupValue(Page $page, Field $field, $value)
string int array objectGiven a raw value (value as stored in database), return the value as it would appear in a Page object.

Other

NameReturnSummary 
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 nullReturn new instance of the Inputfield module associated with this Fieldtype. 
Fieldtype::install()
(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.  
Fieldtype::uninstall()
(nothing)Uninstall this Fieldtype, consistent with optional Module interface
Fieldtype::upgrade($fromVersion, $toVersion)
(nothing)Called when module version changes

Common

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

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.133

Twitter updates

  • ProcessWire 3.0.133 adds a useful new Page::meta() method for a new type of page-specific persistent data storage, adds the ability for users to create their own bookmarks in Lister, and has a handy and time saving update for the asmSelect input type— More
    14 June 2019
  • New post: This week we’ll take a look at 3 different WEBP image strategies that you can use in ProcessWire 3.0.132+. Then we’ll dive into a major update for the Google Client API module, and finish up by outlining some useful new updates in FormBuilder— More
    31 May 2019
  • New post: This week we've added WEBP support in ProcessWire thanks to a GitHub pull request from Horst Nogajski. This enables you to have highly optimized image output in PW and I think you’ll really like the difference it makes— More
    24 May 2019

Latest news

  • ProcessWire Weekly #266
    In the 266th issue of ProcessWire Weekly we're going to take a closer look at ProcessWire 3.0.133 (dev), introduce a third party module called Repeater Images, and highlight a recently released site belonging to the Australian Antarctic Division. Read on!
    Weekly.pw / 15 June 2019
  • ProcessWire 3.0.133 core updates
    ProcessWire 3.0.133 adds a useful new $page->meta() method for a new type of page-specific persistent data storage, adds the ability for users to create their own bookmarks in Lister, and has a handy and time saving update for the asmSelect input type. Read on for all the details, examples and screenshots.
    Blog / 14 June 2019
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani