ElementTrait ​
- Type
- Trait
- Namespace
- craft\base
- Implemented by
- craft\base\Element, craft\elements\Address, craft\elements\Asset, craft\elements\Category, craft\elements\Entry, craft\elements\GlobalSet, craft\elements\Tag, craft\elements\User, craft\test\mockclasses\elements\ExampleElement
- Since
- 3.0.0
ElementTrait implements the common methods and properties for element classes.
Public Properties ​
Property | Description |
---|---|
archived | boolean – Whether the element is archived |
awaitingFieldValues | boolean – Whether the element is still awaiting its custom field values |
dateCreated | DateTime, null – The date that the element was created |
dateDeleted | DateTime, null – The date that the element was trashed |
dateLastMerged | DateTime, null – The date that the canonical element was last merged into this one |
dateUpdated | DateTime, null – The date that the element was last updated |
deletedWithOwner | boolean, null – Whether the element was deleted along with its owner |
draftId | integer, null – The ID of the draft’s row in the drafts table |
duplicateOf | craft\base\ElementInterface, null – The element that this element is being duplicated by. |
eagerLoadInfo | craft\elements\db\EagerLoadInfo, null – Info about the eager loading setup used to query this element. |
elementQueryResult | craft\base\ElementInterface[], null – All elements that the element was queried with. |
enabled | boolean – Whether the element is enabled |
fieldLayoutId | integer, null – The element’s field layout ID |
firstSave | boolean – Whether the element is being saved for the first time in a normal state (not as a draft or revision). |
forceSave | boolean – Whether the element should definitely be saved, if it’s a nested element being considered for saving by \craft\base\NestedElementManager . |
hardDelete | boolean – Whether the element is being hard-deleted. |
id | integer, null – The element’s ID |
isNewForSite | boolean – Whether the element is being saved to the current site for the first time. |
isProvisionalDraft | boolean – Whether this is a provisional draft. |
level | integer, null – The element’s level within its structure |
lft | integer, null – The element’s left position within its structure |
mergingCanonicalChanges | boolean – Whether recent changes to the canonical element are being merged into this element. |
newSiteIds | integer[] – The site IDs that the element was just propagated to for the first time. |
previewing | boolean – Whether the element is currently being previewed. |
propagateAll | boolean – Whether all element attributes should be propagated across all its supported sites, even if that means overwriting existing site-specific values. |
propagating | boolean – Whether the element is being saved in the context of propagating another site's version of the element. |
propagatingFrom | craft\base\ElementInterface, null – The element that this element is being propagated from. |
resaving | boolean – Whether the element is being resaved by a ResaveElement job or a resave console command. |
revisionId | integer, null – The ID of the revision’s row in the revisions table |
rgt | integer, null – The element’s right position within its structure |
root | integer, null – The element’s structure’s root ID |
searchScore | integer, null – The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element |
siteId | integer, null – The site ID the element is associated with |
siteSettingsId | integer, null – The ID of the element’s record in the elements_sites table |
slug | string, null – The element’s slug |
structureId | integer, null – The element’s structure ID |
tempId | string, null – The element’s temporary ID (only used if the element’s URI format contains {id}) |
title | string, null – The element’s title |
trashed | boolean – Whether the element has been soft-deleted. |
uid | string, null – The element’s UID |
updatingFromDerivative | boolean – Whether the element is being updated from a derivative element, such as a draft or revision. |
uri | string, null – The element’s URI |
archived
​
- Type
- boolean
- Default value
false
Whether the element is archived
awaitingFieldValues
​
- Type
- boolean
- Default value
false
Whether the element is still awaiting its custom field values
dateCreated
​
The date that the element was created
dateDeleted
​
The date that the element was trashed
dateLastMerged
​
The date that the canonical element was last merged into this one
dateUpdated
​
The date that the element was last updated
deletedWithOwner
​
Whether the element was deleted along with its owner
draftId
​
The ID of the draft’s row in the drafts
table
duplicateOf
​
- Type
- craft\base\ElementInterface, null
- Default value
null
The element that this element is being duplicated by.
eagerLoadInfo
​
- Type
- craft\elements\db\EagerLoadInfo, null
- Default value
null
- Since
- 5.0.0
Info about the eager loading setup used to query this element.
elementQueryResult
​
- Type
- craft\base\ElementInterface[], null
- Default value
null
- Since
- 5.0.0
All elements that the element was queried with.
enabled
​
- Type
- boolean
- Default value
true
Whether the element is enabled
fieldLayoutId
​
The element’s field layout ID
firstSave
​
- Type
- boolean
- Default value
false
- Since
- 3.7.5
Whether the element is being saved for the first time in a normal state (not as a draft or revision).
forceSave
​
- Type
- boolean
- Default value
false
- Since
- 5.0.0
Whether the element should definitely be saved, if it’s a nested element being considered for saving by \craft\base\NestedElementManager
.
hardDelete
​
- Type
- boolean
- Default value
false
- Since
- 3.2.0
Whether the element is being hard-deleted.
id
​
The element’s ID
isNewForSite
​
- Type
- boolean
- Default value
false
- Since
- 3.7.15
Whether the element is being saved to the current site for the first time.
isProvisionalDraft
​
- Type
- boolean
- Default value
false
- Since
- 3.7.0
Whether this is a provisional draft.
level
​
The element’s level within its structure
lft
​
The element’s left position within its structure
mergingCanonicalChanges
​
- Type
- boolean
- Default value
false
- Since
- 3.7.0
Whether recent changes to the canonical element are being merged into this element.
newSiteIds
​
- Type
- integer[]
- Default value
[]
- Since
- 3.2.9
The site IDs that the element was just propagated to for the first time.
previewing
​
- Type
- boolean
- Default value
false
- Since
- 3.2.0
Whether the element is currently being previewed.
propagateAll
​
- Type
- boolean
- Default value
false
- Since
- 3.2.0
Whether all element attributes should be propagated across all its supported sites, even if that means overwriting existing site-specific values.
propagating
​
- Type
- boolean
- Default value
false
Whether the element is being saved in the context of propagating another site's version of the element.
propagatingFrom
​
- Type
- craft\base\ElementInterface, null
- Default value
null
- Since
- 5.0.0
The element that this element is being propagated from.
resaving
​
- Type
- boolean
- Default value
false
- Since
- 3.1.22
Whether the element is being resaved by a ResaveElement job or a resave
console command.
revisionId
​
The ID of the revision’s row in the revisions
table
rgt
​
The element’s right position within its structure
root
​
The element’s structure’s root ID
searchScore
​
The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element
siteId
​
The site ID the element is associated with
siteSettingsId
​
The ID of the element’s record in the elements_sites
table
slug
​
The element’s slug
structureId
​
The element’s structure ID
tempId
​
The element’s temporary ID (only used if the element’s URI format contains {id})
title
​
The element’s title
trashed
​
- Type
- boolean
- Default value
false
Whether the element has been soft-deleted.
uid
​
The element’s UID
updatingFromDerivative
​
- Type
- boolean
- Default value
false
- Since
- 3.7.0
Whether the element is being updated from a derivative element, such as a draft or revision.
If this is true, the derivative element can be accessed via duplicateOf.
uri
​
The element’s URI