The problem is similar to that one php - SilverStripe display has_one relation values - Stack Overflow
The fields of the one-to-one related object that is connected by ‘belongs_to’ are being shown empty in getCMSFields. It should be noted that the related object is of an extended SilverStripe\Security\Member class. Here are the essential pieces of code:
-
SilverStripe\Security\Member class extension:
class AdsMemberExtension extends DataExtension
{
private static $db = [
‘Nickname’ => ‘Varchar’,
];private static $has_one = [ 'Account' => DataObject::class, ];
}
-
The main class:
class AdvertiserAccount extends DataObject
{
…
private static $belongs_to = [
‘Member’ => ‘SilverStripe\Security\Member.Account’,
];public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.General', [ TextField::create('Member.Nickname', 'Nickname'), ]); ... }
}
I’m surprised that text field ‘Nickname’ leaves blank although $this->Member->Nickname contains the correct data. Please, tell me what’s wrong?