FieldTrait

Type
Trait
Namespace
craft\base
Implemented by
craft\base\Field, craft\fields\Assets, craft\fields\BaseOptionsField, craft\fields\BaseRelationField, craft\fields\Categories, craft\fields\Checkboxes, craft\fields\Color, craft\fields\Date, craft\fields\Dropdown, craft\fields\Email, craft\fields\Entries, craft\fields\Lightswitch, craft\fields\Matrix, craft\fields\MissingField, craft\fields\MultiSelect, craft\fields\Number, craft\fields\PlainText, craft\fields\RadioButtons, craft\fields\Table, craft\fields\Tags, craft\fields\Time, craft\fields\Url, craft\fields\Users
Since
3.0.0

FieldTrait implements the common methods and properties for field classes.

View source (opens new window)

# Public Properties

Property Description
columnPrefix string (opens new window), null (opens new window) – The field’s content column prefix
context string (opens new window), null (opens new window) – The field’s context
groupId integer (opens new window), null (opens new window) – The field’s group’s ID
handle string (opens new window), null (opens new window) – The field’s handle
instructions string (opens new window), null (opens new window) – The field’s instructions
layoutId integer (opens new window), null (opens new window) – The ID of the field layout that the field was fetched from
name string (opens new window), null (opens new window) – The field’s name
oldHandle string (opens new window), null (opens new window) – The field’s previous handle
oldSettings array (opens new window), null (opens new window) – The field’s previous settings
required boolean (opens new window), null (opens new window) – Whether the field is required in the field layout it was fetched from
searchable boolean (opens new window) – Whether the field's values should be registered as search keywords on the elements.
sortOrder integer (opens new window), null (opens new window) – The field’s sort position in the field layout it was fetched from
tabId integer (opens new window), null (opens new window) – The tab ID of the field layout that the field was fetched from
translationKeyFormat string (opens new window), null (opens new window) – The field’s translation key format, if translationMethod is "custom"
translationMethod string (opens new window) – The field’s translation method
uid string (opens new window), null (opens new window) – The field's UID

# columnPrefix

Type
string (opens new window), null (opens new window)
Default value
null

The field’s content column prefix

View source (opens new window)

# context

Type
string (opens new window), null (opens new window)
Default value
null

The field’s context

View source (opens new window)

# groupId

Type
integer (opens new window), null (opens new window)
Default value
null

The field’s group’s ID

View source (opens new window)

# handle

Type
string (opens new window), null (opens new window)
Default value
null

The field’s handle

View source (opens new window)

# instructions

Type
string (opens new window), null (opens new window)
Default value
null

The field’s instructions

View source (opens new window)

# layoutId

Type
integer (opens new window), null (opens new window)
Default value
null

The ID of the field layout that the field was fetched from

View source (opens new window)

# name

Type
string (opens new window), null (opens new window)
Default value
null

The field’s name

View source (opens new window)

# oldHandle

Type
string (opens new window), null (opens new window)
Default value
null

The field’s previous handle

View source (opens new window)

# oldSettings

Type
array (opens new window), null (opens new window)
Default value
null
Since
3.1.2

The field’s previous settings

View source (opens new window)

# required

Type
boolean (opens new window), null (opens new window)
Default value
null

Whether the field is required in the field layout it was fetched from

View source (opens new window)

# searchable

Type
boolean (opens new window)
Default value
false

Whether the field's values should be registered as search keywords on the elements.

View source (opens new window)

# sortOrder

Type
integer (opens new window), null (opens new window)
Default value
null

The field’s sort position in the field layout it was fetched from

View source (opens new window)

# tabId

Type
integer (opens new window), null (opens new window)
Default value
null

The tab ID of the field layout that the field was fetched from

View source (opens new window)

# translationKeyFormat

Type
string (opens new window), null (opens new window)
Default value
null

The field’s translation key format, if translationMethod is "custom"

View source (opens new window)

# translationMethod

Type
string (opens new window)
Default value
\craft\base\Field::TRANSLATION_METHOD_NONE

The field’s translation method

View source (opens new window)

# uid

Type
string (opens new window), null (opens new window)
Default value
null

The field's UID

View source (opens new window)