CP: Title from relation? 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

{date}-{relation_interview_persons[0][firstname][lastname]} 


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