Field represents a custom field that is used on a Page.

Field objects are managed by the $fields API variable.

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

Retrieval / Manipulation / Access / Advanced / Flags / Properties


Name Return Summary  
Field::get(string $key) mixed Get a Field setting or dynamic data property
Field::getConfigInputfields() InputfieldWrapper Get any Inputfields needed to configure the field in the admin.
Field::getDescription() string Return field description for current language, or another specified language.
Field::getFieldgroups() FieldgroupsArray Return the list of Fieldgroups using this field.
Field::getFieldtype() Fieldtype or null Return the Fieldtype module representing this field’s type.
Field::getIcon() mixed or string Return the icon used by this field, or blank if none.
Field::getInputfield(Page $page) Inputfield or null Get the Inputfield module used to collect input for this field.
Field::getLabel() string Get field label for current language, or another specified language.
Field::getNotes() string Return field notes for current language, or another specified language.
Field::getTable() string Get the database table used by this field.
Field::getTemplates() TemplatesArray Return the list of of Templates using this field.
Field::numFieldgroups() int Return the number of Fieldgroups this field is used in.


Name Return Summary  
Field::save() bool Save this field’s settings and data in the database.
Field::set(string $key, mixed $value) $this Set a native setting or a dynamic data property for this Field
Field::setDescription(string $text) (nothing) Set description, optionally for a specific language
Field::setFieldtype($type) Field Set what type of field this is (Fieldtype).
Field::setIcon(string $icon) $this Set the icon for this field
Field::setLabel(string $text) (nothing) Set label, optionally for a specific language
Field::setName(string $name) Field Set the field’s name
Field::setNotes(string $text) (nothing) Set notes, optionally for a specific language
Field::setRoles(string $type, $roles) (nothing) Set the roles that are allowed to view or edit this field on pages.


Name Return Summary  
Field::editRoles array Role IDs with edit access, applicable only if access control is enabled.
Field::editable() bool Is this field editable?
Field::useRoles bool Whether or not access control is enabled
Field::viewRoles array Role IDs with view access, applicable only if access control is enabled.
Field::viewable() bool Is this field viewable?


Name Return Summary  
Field::setTable() (nothing) Set an override table name, or omit (or null) to restore default table name


Name Return Summary  
Field::addFlag(int $flag) $this Add the given bitmask flag
Field::flagAccess const 32 Field is access controlled
Field::flagAccessAPI const 64 If field is access controlled, this flag says that values are still front-end API accessible Without this flag, non-viewable values are made blank when output formatting is ON.
Field::flagAccessEditor const 128 If field is access controlled and user has no edit access, they can still view in the editor (if they have view permission) Without this flag, non-editable values are simply not shown in the editor at all.
Field::flagAutojoin const 1 Field should be automatically joined to the page at page load time
Field::flagFieldgroupContext const 2048 Field has been placed in a runtime state where it is contextual to a specific fieldgroup and is no longer saveable
Field::flagGlobal const 4 Field used by all fieldgroups - all fieldgroups required to contain this field
Field::flagPermanent const 16 Field is permanent in any fieldgroups/templates where it exists - it may not be removed from them
Field::flagSystem const 8 Field is a system field and may not be deleted, have it's name changed, or be converted to non-system
Field::flagSystemOverride const 32768 Set this flag to override system/permanent flags if necessary - once set, system/permanent flags can be removed, but not in the same set().
Field::hasFlag(int $flag) bool Does this field have the given bitmask flag?
Field::removeFlag(int $flag) $this Remove the given bitmask flag


Name Return Summary  
Field::columnWidth int or null The Inputfield column width (percent) 10-100.
Field::description string Longer description text for the field
Field::flags int Bitmask of flags used by this field
Field::icon string Icon name used by the field, if applicable
Field::id int Numeric ID of field in the database
Field::label string Text string representing the label of the field
Field::name string Name of field
Field::notes string Additional notes text about the field
Field::prevFieldtype Fieldtype Previous Fieldtype, of type was changed
Field::prevTable string Previously database table (if field was renamed)
Field::required int or bool or null Whether or not this field is required during input
Field::requiredIf string or null A selector-style string that defines the conditions under which input is required
Field::showIf string or null A selector-style string that defines the conditions under which the Inputfield is shown
Field::table string Database table used by the field
Field::type Fieldtype or null Fieldtype module that represents the type of this field

Additional methods and properties

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