$fields

Manages all custom fields in ProcessWire, independently of any Fieldgroup.

Each field returned is an object of type Field. The $fields API variable is iterable:

foreach($fields as $field) {
  echo "<p>Name: $field->name, Type: $field->type, Label: $field->label</p>";
}

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.

Show $var?     Show args?       Only hookable?    

Common

NameReturnSummary 
clone(Field $item)
FieldCreate and return a cloned copy of the given Field
delete(Field $item)
boolDelete a Field from the database
findByTag(string $tag)
arrayReturn all fields that have the given $tag 
findByType($type)
array FieldFind fields by type 
get($key)
Field nullGet a field by name or id
getAllNames()
arrayGet all field names 
getCacheItemName()
None 
getNumPages(Field $field)
int arrayReturn a count of pages containing populated values for the given field 
getNumRows(Field $field)
int arrayReturn a count of database rows populated the given field 
getWireArray()
WireArrayGet WireArray container that items are stored in 
isNative(string $name)
boolIs the given field name native/permanent to the database? 
makeItem()
Saveable WireMake an item and populate with given data 
save(Field $item)
boolSave a Field to the database

Additional methods and properties

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

API reference based on ProcessWire core version 3.0.251