Skip to content

ElementContainerFieldInterface

Type
Interface
Namespace
craft\base
Extends
craft\base\FieldInterface
Implemented by
craft\fields\Addresses, craft\fields\Matrix
Since
5.0.0

ElementContainerFieldInterface defines the common interface to be implemented by field classes that contain nested elements, which implement craft\base\NestedElementInterface.

View source

Public Methods

MethodDescription
afterDelete()Performs actions after a component is deleted.
afterElementDelete()Performs actions after the element has been deleted.
afterElementDeleteForSite()Performs actions after the element has been deleted.
afterElementPropagate()Performs actions after the element has been fully saved and propagated to other sites.
afterElementRestore()Performs actions after the element has been restored.
afterElementSave()Performs actions after the element has been saved.
afterSave()Performs actions after a component is saved.
beforeApplyDelete()Performs actions before a component delete is applied to the database.
beforeDelete()Performs actions before a component is deleted.
beforeElementDelete()Performs actions before an element is deleted.
beforeElementDeleteForSite()Performs actions before an element is deleted for a site.
beforeElementRestore()Performs actions before an element is restored.
beforeElementSave()Performs actions before an element is saved.
beforeSave()Performs actions before a component is saved.
canDeleteElement()Returns whether the given user is authorized to delete an element.
canDeleteElementForSite()Returns whether the given user is authorized to delete an element for its current site.
canDuplicateElement()Returns whether the given user is authorized to duplicate an element.
canSaveElement()Returns whether the given user is authorized to save an element in its current form.
canViewElement()Returns whether the given user is authorized to view an element’s edit page.
copyValue()Copies the field’s value from one element to another.
dbType()Returns the DB data type(s) that this field will store within the elements_sites.content column.
displayName()Returns the display name of this class.
extraFields()Returns the list of additional fields that can be returned by toArray() in addition to those listed in fields().
fields()Returns the list of fields that should be returned by default by toArray() when no specific fields are specified.
get()Returns a component by its ID.
getContentGqlMutationArgumentType()Returns the GraphQL type to be used as an argument in mutations for this field type.
getContentGqlQueryArgumentType()Returns the GraphQL type to be used as an argument in queries for this field type.
getContentGqlType()Returns the GraphQL type to be used for this field type.
getCpEditUrl()Returns the URL to the component’s edit page in the control panel.
getElementConditionRuleType()Returns the element condition rule class that should be used for this field.
getElementValidationRules()Returns the validation rules for an element with this field.
getFieldLayoutProviders()Returns the field layout providers that could be involved in nested elements.
getHandle()Returns the handle of the component.
getId()Returns the ID of the component, which should be used as the value of hidden inputs.
getInputHtml()Returns the field’s input HTML.
getInputId()Returns the input’s ID, which the <label>’s for attribute should reference.
getIsNew()Returns whether the component is new (unsaved).
getIsTranslatable()Returns whether the field should be shown as translatable in the UI.
getLabelId()Returns the input’s label ID.
getOrientation()Returns the orientation the field should use (ltr or rtl).
getRouteForElement()Returns the route that should be used when a nested element’s URI is requested.
getSearchKeywords()Returns the search keywords that should be associated with this field.
getSettings()Returns an array of the component’s settings.
getSettingsHtml()Returns the component’s settings HTML.
getStaticHtml()Returns a static (non-editable) version of the field’s input HTML.
getStatus()Returns the status of the field for a given element.
getSupportedSitesForElement()Returns the sites a nested element is associated with.
getTranslationDescription()Returns the description of this field’s translation support.
getTranslationKey()Returns the field’s translation key, based on a given element.
getUiLabel()Returns what the component should be called within the control panel.
getUriFormatForElement()Returns the URI format for a nested element.
getValueSql()Returns a SQL expression which extracts the field’s value from the elements_sites.content column.
icon()Returns the field type’s SVG icon.
includeInGqlSchema()Returns whether the field should be included in the given GraphQL schema.
instance()Returns static class instance, which can be used to obtain meta information.
isMultiInstance()Returns whether the field can be included multiple times within a field layout.
isRequirable()Returns whether the field can be marked as required.
isSelectable()Returns whether the component should be selectable in component Type selects.
isValueEmpty()Returns whether the given value should be considered “empty” to a validator.
modifyElementIndexQuery()Modifies an element index query.
normalizeValue()Normalizes the field’s value for use.
normalizeValueFromRequest()Normalizes a posted field value for use.
phpType()Returns the PHPDoc type this field’s values will have.
queryCondition()Returns a query builder-compatible condition for the given field instances, for a user-provided param value.
serializeValue()Prepares the field’s value to be stored somewhere, like the content table.
setIsFresh()Sets whether the field is fresh.
settingsAttributes()Returns the list of settings attribute names.
supportedTranslationMethods()Returns which translation methods the field supports.
toArray()Converts the object into an array.
useFieldset()Returns whether the field should use a <fieldset> + <legend> instead of a <div> + <label>.

canDeleteElement()

Returns whether the given user is authorized to delete an element.

This will only be called if the element can be \craft\base\canView() and/or \craft\base\canSave().

View source

Arguments

Returns

boolean, null

canDeleteElementForSite()

Returns whether the given user is authorized to delete an element for its current site.

This will only be called if the element can be \craft\base\canView() and/or \craft\base\canSave().

View source

Arguments

Returns

boolean, null

canDuplicateElement()

Returns whether the given user is authorized to duplicate an element.

This will only be called if the element can be \craft\base\canView() and/or \craft\base\canSave().

View source

Arguments

Returns

boolean, null

canSaveElement()

Returns whether the given user is authorized to save an element in its current form.

This will only be called if the element can be \craft\base\canView().

View source

Arguments

Returns

boolean, null

canViewElement()

Returns whether the given user is authorized to view an element’s edit page.

If they can view but not \craft\base\canSave(), the edit form will either render statically, or be restricted to only saving changes as a draft, depending on \craft\base\canCreateDrafts().

View source

Arguments

Returns

boolean, null

getFieldLayoutProviders()

Returns the field layout providers that could be involved in nested elements.

View source

Returns

craft\base\FieldLayoutProviderInterface[]

getRouteForElement()

Returns the route that should be used when a nested element’s URI is requested.

View source

Arguments

Returns

mixed – The route that the request should use, or null if no special action should be taken

getSupportedSitesForElement()

Returns the sites a nested element is associated with.

The function can either return an array of site IDs, or an array of sub-arrays, each with the following keys:

  • siteId (integer) - The site ID
  • propagate (boolean) – Whether the element should be propagated to this site on save (true by default)
  • enabledByDefault (boolean) – Whether the element should be enabled in this site by default (true by default)

View source

Arguments

  • $element

Returns

array

getUriFormatForElement()

Returns the URI format for a nested element.

View source

Arguments

Returns

string, null