Skip to main content
Version: 2024.2

Relation (Many-To-One) Editable


The relation editable provides the functionality to create a reference to another element in Pimcore (document, asset, object). In frontend-mode this editable returns the path of the linked element.


typesarrayAllowed types (document, asset, object), if empty all types are allowed
subtypesarrayAllowed subtypes grouped by type (folder, page, snippet, image, video, object, ...), if empty all subtypes are allowed (see example below)
classesarrayAllowed object class names, if empty all classes are allowed
reloadbooleantrue triggers page reload on each change
widthintWidth of the field in pixel.
uploadPathstringTarget path for (inline) uploaded assets
classstringA CSS class that is added to the surrounding container of this element in editmode


getElement()ElementGet the assigned element
getFullPath()stringGet the full path of the assigned element.
isEmpty()booleanWhether the editable is empty or not


Basic usage

You can just create the code line like, below:

{{ pimcore_relation("myRelation") }}

After, the view in the administration panel changes like in the picture:

Relation editable preview in the administration panelRelation editable preview in the administration panelRelation editable preview in the administration panel

Using Restriction

If you want specify elements which could be assigned to the relation editable, use types, subtypes and classes options in the editable configuration.

{{ pimcore_relation("myRelation", {
"types": ["asset","object"],
"subtypes": {
"asset": ["video", "image"],
"object": ["object"],
"classes": ["person"]
}) }}

We restricted the myRelation editable to the following entities:

  • Video / Image (Assets)
  • Person Objects (\Pimcore\Model\DataObject\Person) (Objects)

As you see in the picture below, it's impossible to drop any other type to that editable.

Relation restrictionRelation restrictionRelation restriction

Download Example

Another useful use-case for the relation editable is a download link.

{% if editmode %}
{{ pimcore_relation("myRelation") }}
{% else %}
{% if pimcore_relation("myRelation").getElement() is instanceof('\\Pimcore\\Model\\Asset') %}
<a href="{{ pimcore_relation("myRelation").getFullPath() }}">{{ "Download" | trans }}</a>
{% endif %}
{% endif %}