Skip to content

RelationalFieldInterface

Type
Interface
Namespace
craft\base
Extends
craft\base\FieldInterface
Implemented by
craft\fields\Assets, craft\fields\BaseRelationField, craft\fields\Categories, craft\fields\Entries, craft\fields\Link, craft\fields\Tags, craft\fields\Users
Since
5.3.0

RelationalFieldInterface defines the common interface to be implemented by field classes which can store relation data.

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.
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.
forceUpdateRelations()Returns whether relations should be updated for the field.
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.
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).
getRelationTargetIds()Returns the related element IDs for this field.
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.
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.
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.
localizeRelations()Returns whether relations stored for the field should include the source element’s site ID.
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>.

forceUpdateRelations()

Returns whether relations should be updated for the field.

View source

Arguments

Returns

boolean

getRelationTargetIds()

Returns the related element IDs for this field.

View source

Arguments

Returns

integer[]

localizeRelations()

Returns whether relations stored for the field should include the source element’s site ID.

Note that this must be consistent across all instances of the same field.

View source

Returns

boolean