NestedElementInterface
- Type
- Interface
- Namespace
- craft\base
- Extends
- craft\base\ElementInterface
- Implemented by
- craft\elements\Address, craft\elements\ContentBlock, craft\elements\Entry
- Since
- 5.0.0
NestedElementInterface defines the common interface to be implemented by elements that can be nested within other elements via a custom field.
craft\base\NestedElementTrait provides a base implementation.
Public Methods
| Method | Description |
|---|---|
| __toString() | Returns the string representation of the element. |
| actions() | Returns the available bulk element actions for a given source. |
| addInvalidNestedElementIds() | Registers invalid nested element IDs with the element, so an error class can be added on their cards. |
| afterDelete() | Performs actions after an element is deleted. |
| afterDeleteForSite() | Performs actions after an element is deleted for a site. |
| afterMoveInStructure() | Performs actions after an element is moved within a structure. |
| afterPropagate() | Performs actions after an element is fully saved and propagated to other sites. |
| afterRestore() | Performs actions after an element is restored. |
| afterSave() | Performs actions after an element is saved. |
| attributePreviewHtml() | Return HTML for the attribute in the card preview. |
| baseBulkDuplicateAttributes() | Returns the base attributes that should be applied when bulk-duplicating elements of this type. |
| baseGqlType() | Returns the base GraphQL type name that represents elements of this type. |
| beforeDelete() | Performs actions before an element is deleted. |
| beforeDeleteForSite() | Performs actions before an element is deleted for a site. |
| beforeMoveInStructure() | Performs actions before an element is moved within a structure. |
| beforeRestore() | Performs actions before an element is restored. |
| beforeSave() | Performs actions before an element is saved. |
| canCopy() | Returns whether the given user is authorized to copy this element, to be duplicated elsewhere. |
| canCreateDrafts() | Returns whether the given user is authorized to create drafts for this element. |
| canDelete() | Returns whether the given user is authorized to delete this element. |
| canDeleteForSite() | Returns whether the given user is authorized to delete this element for its current site. |
| canDuplicate() | Returns whether the given user is authorized to duplicate this element. |
| canDuplicateAsDraft() | Returns whether the given user is authorized to duplicate this element as an unpublished draft. |
| canSave() | Returns whether the given user is authorized to save this element in its current form. |
| canView() | Returns whether the given user is authorized to view this element’s edit page. |
| cardAttributes() | Defines all the available attributes that can be shown in card views. |
| createAnother() | Creates a new element (without saving it) based on this one. |
| createCondition() | Returns an element condition for the element type. |
| defaultCardAttributes() | Returns the list of card attribute keys that should be shown by default, if the field layout hasn't been customised. |
| defaultTableAttributes() | Returns the list of table attribute keys that should be shown by default. |
| displayName() | Returns the display name of this class. |
| eagerLoadingMap() | Returns an array that maps source-to-target element IDs based on the given sub-property handle. |
| exporters() | Returns the available export options for a given source. |
| extraFields() | Returns the list of additional fields that can be returned by toArray() in addition to those listed in fields(). |
| fieldLayouts() | Returns all the field layouts associated with elements from the given source. |
| fields() | Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. |
| find() | Creates an craft\elements\db\ElementQueryInterface instance for query purpose. |
| findAll() | Returns a list of elements that match the specified ID(s) or a set of element criteria parameters. |
| findOne() | Returns a single element instance by a primary key or a set of element criteria parameters. |
| findSource() | Returns a source definition by a given source key/path and context. |
| get() | Returns a component by its ID. |
| getActionMenuItems() | Returns action menu items for the component. |
| getAdditionalButtons() | Returns additional buttons that should be shown at the top of the element’s edit page. |
| getAltActions() | Returns alternative form actions for the element. |
| getAncestors() | Returns the element’s ancestors. |
| getAttributeHtml() | Returns the HTML that should be shown for a given attribute in table and card views. |
| getAttributeStatus() | Returns the status of a given attribute. |
| getCacheTags() | Returns the cache tags that should be cleared when this element is saved. |
| getCanonical() | Returns the canonical version of the element. |
| getCanonicalId() | Returns the element’s canonical ID. |
| getCanonicalUid() | Returns the element’s canonical UUID. |
| getCardBodyHtml() | Returns the body HTML for element cards. |
| getCardTitle() | Returns the titlebar label for element cards. |
| getChildren() | Returns the element’s children. |
| getChipLabelHtml() | Returns the label HTML for element chips. |
| getCpEditUrl() | Returns the URL to the component’s edit page in the control panel. |
| getCpRevisionsUrl() | Returns the element’s revisions index URL in the control panel. |
| getCrumbs() | Returns the breadcrumbs that lead up to the element. |
| getCurrentRevision() | Returns the element’s current revision, if one exists. |
| getDescendants() | Returns the element’s descendants. |
| getDirtyAttributes() | Returns a list of attribute names that have changed since the element was first loaded. |
| getDirtyFields() | Returns a list of custom field handles that have changed since the element was first loaded. |
| getEagerLoadedElementCount() | Returns the count of eager-loaded elements for a given handle. |
| getEagerLoadedElements() | Returns the eager-loaded elements for a given handle. |
| getEnabledForSite() | Returns whether the element is enabled for the current site. |
| getField() | Returns the field that contains the element. |
| getFieldContext() | Returns the field context this element’s content uses. |
| getFieldLayout() | Returns the field layout used by this element. |
| getFieldParamNamespace() | Returns the namespace used by custom field params on the request. |
| getFieldValue() | Returns the value for a given field. |
| getFieldValues() | Returns the element’s normalized custom field values, indexed by their handles. |
| getGeneratedFieldValues() | Returns the generated field values for the element, indexed by handle. |
| getGqlTypeName() | Returns the GraphQL type name for this element type. |
| getHasDescendants() | Returns whether the element has descendants. |
| getHtmlAttributes() | Returns any attributes that should be included in the element’s chips and cards. |
| getId() | Returns the ID of the component, which should be used as the value of hidden inputs. |
| getInlineAttributeInputHtml() | Returns the HTML that should be shown for a given attribute's inline editing input. |
| getInvalidNestedElementIds() | Returns the element’s invalid nested element IDs. |
| getIsCanonical() | Returns whether this is the canonical element. |
| getIsCrossSiteCopyable() | Return if the element is copyable between sites. |
| getIsDerivative() | Returns whether this is a derivative element, such as a draft or revision. |
| getIsDraft() | Returns whether this is a draft. |
| getIsFresh() | Returns whether the element is "fresh" (not yet explicitly saved, and without validation errors). |
| getIsHomepage() | Returns whether this element represents the site homepage. |
| getIsRevision() | Returns whether this is a revision. |
| getIsSlugTranslatable() | Returns whether the Slug field should be shown as translatable in the UI. |
| getIsTitleTranslatable() | Returns whether the Title field should be shown as translatable in the UI. |
| getIsUnpublishedDraft() | Returns whether the element is an unpublished draft. |
| getLanguage() | Returns the language of the element. |
| getLink() | Returns an anchor pre-filled with this element’s URL and title. |
| getLocalized() | Returns the same element in other locales. |
| getMetadata() | Returns element metadata that should be shown within the editor sidebar. |
| getModifiedAttributes() | Returns the attribute names that have changed for this element. |
| getModifiedFields() | Returns the field handles that have changed for this element. |
| getNext() | Returns the next element relative to this one, from a given set of criteria. |
| getNextSibling() | Returns the element’s next sibling. |
| getOutdatedAttributes() | Returns the attribute names that have been updated on the canonical element since the last time it was merged into this element. |
| getOutdatedFields() | Returns the field handles that have been updated on the canonical element since the last time it was merged into this element. |
| getOwner() | Returns the owner element, if the element has one. |
| getOwnerId() | Returns the owner element’s ID, if the element has one. |
| getOwners() | Returns each of the element’s owners |
| getParent() | Returns the element’s parent. |
| getParentUri() | Returns the parent element’s URI, if there is one. |
| getPostEditUrl() | Returns the URL that users should be redirected to after editing the element. |
| getPrev() | Returns the previous element relative to this one, from a given set of criteria. |
| getPrevSibling() | Returns the element’s previous sibling. |
| getPreviewTargets() | Returns the additional locations that should be available for previewing the element, besides its primary URL. |
| getPrimaryOwner() | Returns the primary owner element, if the element has one. |
| getPrimaryOwnerId() | Returns the primary owner element’s ID, if the element has one. |
| getRef() | Returns the reference string to this element. |
| getRootOwner() | Returns the root owner element. |
| getRoute() | Returns the route that should be used when the element’s URI is requested. |
| getSearchKeywords() | Returns the search keywords for a given search attribute. |
| getSerializedFieldValues() | Returns an array of the element’s serialized custom field values, indexed by their handles. |
| getSerializedFieldValuesForDb() | Returns an array of the element’s serialized custom field values, indexed by their handles, for database storage. |
| getSiblings() | Returns all of the element’s siblings. |
| getSidebarHtml() | Returns the HTML for any fields/info that should be shown within the editor sidebar. |
| getSite() | Returns the site the element is associated with. |
| getSlugTranslationDescription() | Returns the description of the Slug field’s translation support. |
| getSlugTranslationKey() | Returns the Slug’s translation key. |
| getSortOrder() | Returns the element’s sort order, if it has one. |
| getStatus() | Returns the component’s status. |
| getSupportedSites() | Returns the sites this element is associated with. |
| getThumbHtml() | Returns the HTML for the component’s thumbnail, if it has one. |
| getTitleTranslationDescription() | Returns the description of the Title field’s translation support. |
| getTitleTranslationKey() | Returns the Title’s translation key. |
| getTotalDescendants() | Returns the total number of descendants that the element has. |
| getUiLabel() | Returns what the component should be called within the control panel. |
| getUiLabelPath() | Returns any path segment labels that should be prepended to the element’s UI label. |
| getUriFormat() | Returns the URI format used to generate this element’s URI. |
| getUrl() | Returns the element’s full URL. |
| gqlScopesByContext() | Returns the GraphQL scopes required by element’s context. |
| hasDrafts() | Returns whether element indexes should show the “Drafts” status option. |
| hasEagerLoadedElements() | Returns whether elements have been eager-loaded with a given handle. |
| hasRevisions() | Returns whether revisions should be created when this element is saved. |
| hasStatuses() | Returns whether elements of this type have statuses. |
| hasThumbs() | Returns whether element indexes should include a thumbnail view by default. |
| hasTitles() | Returns whether elements of this type have traditional titles. |
| hasUris() | Returns whether elements of this type can have their own slugs and URIs. |
| indexElementCount() | Returns the total number of elements that will be shown on an element index, for the given element query. |
| indexHtml() | Returns the element index HTML. |
| indexViewModes() | Returns the view modes available for the element type. |
| instance() | Returns static class instance, which can be used to obtain meta information. |
| isAncestorOf() | Returns whether this element is an ancestor of another one. |
| isAttributeDirty() | Returns whether an attribute has changed since the element was first loaded. |
| isAttributeModified() | Returns whether an attribute value has changed for this element. |
| isAttributeOutdated() | Returns whether an attribute value has fallen behind the canonical element’s value. |
| isChildOf() | Returns whether this element is a direct child of another one. |
| isDescendantOf() | Returns whether this element is a descendant of another one. |
| isFieldDirty() | Returns whether a custom field value has changed since the element was first loaded. |
| isFieldEmpty() | Returns whether a field is empty. |
| isFieldModified() | Returns whether a field value has changed for this element. |
| isFieldOutdated() | Returns whether a field value has fallen behind the canonical element’s value. |
| isLocalized() | Returns whether elements of this type store content on a per-site basis. |
| isNextSiblingOf() | Returns whether this element is the direct next sibling of another one. |
| isParentOf() | Returns whether this element is a direct parent of another one. |
| isPrevSiblingOf() | Returns whether this element is the direct previous sibling of another one. |
| isSelectable() | Returns whether the component should be selectable in component Type selects. |
| isSiblingOf() | Returns whether this element is a sibling of another one. |
| lowerDisplayName() | Returns the lowercase version of displayName(). |
| markAsClean() | Resets the record of dirty attributes and fields. |
| markAsDirty() | Marks all fields and attributes as dirty. |
| mergeCanonicalChanges() | Merges changes from the canonical element into this one. |
| modifyCustomSource() | Modifies a custom source’s config, before it’s returned by craft\services\ElementSources::getSources() |
| offsetExists() | Treats custom fields as array offsets. |
| pluralDisplayName() | Returns the plural version of displayName(). |
| pluralLowerDisplayName() | Returns the plural, lowercase version of displayName(). |
| prepareEditScreen() | Prepares the response for the element’s Edit screen. |
| refHandle() | Returns the handle that should be used to refer to this element type from reference tags. |
| render() | Renders the element using its partial template. |
| searchableAttributes() | Defines which element attributes should be searchable. |
| setAttributesFromRequest() | Sets the element’s attributes from an element editor submission. |
| setCanonical() | Sets the canonical version of the element. |
| setCanonicalId() | Sets the element’s canonical ID. |
| setDirtyAttributes() | Sets the list of dirty attribute names. |
| setDirtyFields() | Sets the list of dirty field handles. |
| setEagerLoadedElementCount() | Sets the count of eager-loaded elements for a given handle. |
| setEagerLoadedElements() | Sets some eager-loaded elements on a given handle. |
| setEnabledForSite() | Sets whether the element is enabled for the current site. |
| setFieldParamNamespace() | Sets the namespace used by custom field params on the request. |
| setFieldValue() | Sets the value for a given field. |
| setFieldValueFromRequest() | Sets the value for a given field. The value should have originated from post data. |
| setFieldValues() | Sets the element’s custom field values. |
| setFieldValuesFromRequest() | Sets the element’s custom field values, when the values have come from post data. |
| setGeneratedFieldValues() | Sets the generated field values for the element, indexed by handle. |
| setIsFresh() | Sets whether the element is "fresh" (not yet explicitly saved, and without validation errors). |
| setLazyEagerLoadedElements() | Sets whether the given eager-loaded element handles were eager-loaded lazily. |
| setNext() | Sets the default next element. |
| setOwner() | Sets the owner element, if the element has one. |
| setOwnerId() | Sets the owner element’s ID, if the element has one. |
| setParent() | Sets the element’s parent. |
| setPrev() | Sets the default previous element. |
| setPrimaryOwner() | Sets the primary owner element, if the element has one. |
| setPrimaryOwnerId() | Sets the primary owner element’s ID, if the element has one. |
| setRevisionCreatorId() | Sets the revision creator ID to be saved. |
| setRevisionNotes() | Sets the revision notes to be saved. |
| setSaveOwnership() | Sets whether the element’s ownership should be saved when the element is saved. |
| setSortOrder() | Sets the element’s sort order. |
| setUiLabel() | Defines what the element should be called within the control panel. |
| setUiLabelPath() | Defines any path segment labels that should be prepended to the element’s UI label. |
| showStatusIndicator() | Returns whether chips and cards for this element should include a status indicator. |
| sortOptions() | Returns the sort options for the element type. |
| sourcePath() | Returns the source path for a given source key, step key, and context. |
| sources() | Returns the source definitions that elements of this type may belong to. |
| statuses() | Returns all the possible statuses that components may have. |
| tableAttributes() | Defines all of the available columns that can be shown in table views. |
| toArray() | Converts the object into an array. |
| trackChanges() | Returns whether Craft should keep track of attribute and custom field changes made to this element type, including when the last time they were changed, and who was logged-in at the time. |
getField()
Returns the field that contains the element.
Returns
craft\base\ElementContainerFieldInterface, null
Throws
- yii\base\InvalidConfigException
if the element is misconfigured
getOwner()
Returns the owner element, if the element has one.
Returns
craft\base\ElementInterface, null
Throws
- yii\base\InvalidConfigException
if the element is misconfigured
getOwnerId()
Returns the owner element’s ID, if the element has one.
Returns
Throws
- yii\base\InvalidConfigException
if the element is misconfigured
getOwners()
- Since
- 5.8.17
Returns each of the element’s owners
Arguments
$criteria(array)
Returns
Throws
- yii\base\InvalidConfigException
if the element is misconfigured
getPrimaryOwner()
Returns the primary owner element, if the element has one.
Returns
craft\base\ElementInterface, null
Throws
- yii\base\InvalidConfigException
if the element is misconfigured
getPrimaryOwnerId()
Returns the primary owner element’s ID, if the element has one.
Returns
Throws
- yii\base\InvalidConfigException
if the element is misconfigured
getSortOrder()
Returns the element’s sort order, if it has one.
Returns
setOwner()
Sets the owner element, if the element has one.
Arguments
$owner(craft\base\ElementInterface, null)
setOwnerId()
Sets the owner element’s ID, if the element has one.
Arguments
setPrimaryOwner()
Sets the primary owner element, if the element has one.
Arguments
$owner(craft\base\ElementInterface, null)
setPrimaryOwnerId()
Sets the primary owner element’s ID, if the element has one.
Arguments
setSaveOwnership()
Sets whether the element’s ownership should be saved when the element is saved.
Arguments
$saveOwnership(boolean)
setSortOrder()
Sets the element’s sort order.