Title is the default display value for pretty much any basic presentation of a DataObject
in the CMS.
But not all DataObject
s have a Title, so the class DataObject
has a method getTitle()
which returns "#{$this->ID}
.
there are 2 ways to solve your problem:
overwrite
getTitle()
in your DataObject (the Mentor)public function getTitle() { return "{$this->Firstname} {$this->Lastname}"; }
tell the search field thingy on the GridField to use something else than title (example code according to the tutorial)
class Project extends Page { public function getCMSFields() { $config = new GridFieldConfig_RelationEditor(); $autoCompleteComponent = $config->getComponentByType('GridFieldAddExistingAutocompleter'); $autoCompleteComponent->setResultsFormat('$FirstName $LastName'); $mentorsField = new GridField( 'Mentors', 'Mentors', $this->Mentors(), $config ); $fields->addFieldToTab('Root.Mentors', $mentorsField); return $fields; } }