I have the following 1:n relation between two sections:

  • Source Element: Interview
  • Target Element: Persons

In the CP (only there) I need to be able to identify Interviews by the name of the interviewed persons.

So in the title format field for the entry type I tried something like


But that's no good.

Is that even a valid approach? Of course, we can simply use a custom title and that's it.


relation_interview_persons is not an array of elements but an object of type ElementQuery. In order to get the results you need to call one().

Keep in mind chances are high there is no related element if that's the case your code will throw an exception.

{% set person = object.relation_interview_persons.one() %} {{ person? person.firstname : ''}}

If date is not a field of type text but a Date field that will throw an exception as well since it's an object and no string

  • Wohee, thanks! I now did {% set person = object.relation_interview_persons.one() %} {{ person? person.firstname : ''}} {{ person? person.lastname : ''}} ({{date|date("d.m.Y")}}) so also the date is output correctly. I've set all those fields to required.
    – Urs
    Aug 28 '18 at 20:41
  • So as long as it's on one line, any twig code will work there? (I'm thinking about looping through the last names of all used persons)
    – Urs
    Aug 28 '18 at 20:41
  • 1
    The line number doesn't matter.. You can write what you want since it's treated as an normal Twig template. If you feel like it, you can even update other elements within the template or create fancy queries and such Aug 28 '18 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.