Good day,
I have a data object manager loaded on a page as per below:
class XYZPage extends Page
{
static $has_many = array (
'CustomModels' => 'CustomModel'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.CustomWidgets", new DataObjectManager(
$this,
'CustomModels',
'CustomModel',
array('CustomName'=>'Custom Model Name', 'CustomParentPageID'=>'Custom Parent Page ID'),
'getCMSFields_forPopup'
));
return $fields;
}
}
class CustomModel extends DataObject
{
static $db = array (
'CustomName' => 'varchar(255)'
);
static $has_one = array (
'CustomParentPage' => 'SiteTree'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('WidgetName', 'Widget Name'),
new SimpleTreeDropdownField('CustomParentPageID', 'Parent Page', 'SiteTree')
);
}
}
The CustomModel has a one to one relationship with the SiteTree table (CustomParentPage). In the getCMSFields function (XYZPage) I can print the CustomParentPageID as a column in the DOM. Is it possible to add that page Title (or other properties related to that class) in the DOM? If so would someone mind steering me in the right direction?
I would ideally like to do something similar to this:
$fields->addFieldToTab("Root.Content.CustomWidgets", new DataObjectManager(
$this,
'CustomModels',
'CustomModel',
array('CustomName'=>'Custom Model Name', 'CustomParentPageID'=>'Custom Parent Page ID',
'CustomParentPage->Title'=>'Custom Parent Page Title' // <-- is something like this possible?
),
'getCMSFields_forPopup'
));