Manages all custom fields in ProcessWire

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Fields class also inherits all the methods and properties of: WireSaveableItems and Wire.

Common / Advanced / For hooks


Name Return Summary  
$fields->clone($item) bool or Saveable Create and return a cloned copy of the given Field
$fields->delete($item) bool Delete a Field from the database
$fields->get($key) Field or null Get a field by name or id
$fields->getNumPages(Field $field) int or array Return a count of pages containing populated values for the given field
$fields->getNumRows(Field $field) int or array Return a count of database rows populated the given field
$fields->isNative(string $name) bool Is the given field name native/permanent to the database?
$fields->save($item) bool Save a Field to the database


Name Return Summary  
$fields->saveFieldgroupContext(Field $field, Fieldgroup $fieldgroup) bool Save the context of the given field for the given fieldgroup

For hooks

This methods are only useful for hooking and should not be called directly.

Name Return Summary  
$fields->changeFieldtype(Field $field1) bool Change a field's type
$fields->changeTypeReady($item, Fieldtype $fromType, Fieldtype $toType) (nothing) Hook called right before a field is about to change type
$fields->changedType($item, Fieldtype $fromType, Fieldtype $toType) (nothing) Hook called when a field has changed type
$fields->deleteFieldDataByTemplate(Field $field, Template $template) bool Physically delete all field data (from the database) used by pages of a given template

Additional methods and properties

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