$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 
$fields->clone(Field $item)
Field

Create and return a cloned copy of the given Field

$fields->delete(Field $item)
bool

Delete a Field from the database

$fields->findByTag(string $tag)
array

Return all fields that have the given $tag

 
$fields->findByType($type)
array Field

Find fields by type

 
$fields->get($key)
Field nullGet a field by name or id
$fields->getAllNames()
array

Get all field names

 
$fields->getCacheItemName()
None 
$fields->getNumPages(Field $field)
int array

Return a count of pages containing populated values for the given field

 
$fields->getNumRows(Field $field)
int array

Return a count of database rows populated the given field

 
$fields->getWireArray()
WireArray

Get WireArray container that items are stored in

 
$fields->isNative(string $name)
bool

Is the given field name native/permanent to the database?

 
$fields->makeItem()
Saveable Wire

Make an item and populate with given data

 
$fields->save(Field $item)
bool

Save 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.252