EDIT - Ok so I just tried CTF and it gave me this error on save:
Fatal error: Call to a member function getComponents() on a non-object in /home/aabfbo/public_html/dev/sapphire/forms/ComplexTableField.php on line 661
Which means this line is returning nothing:
$parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
So I guess this is not a DOM issue, but perhaps you will be able to shed a little more light on it than I can? Looks like it's not getting the ID from the SiteConfig DataObject.... Thanks UC :)
/EDIT
Hi UC
I have been testing out using the DOM in the SiteConfig of 2.4 Rc1 using the DOM r393. here is my code:
DataObject:
<?php
class Link extends DataObject {
static $has_one = array (
'SiteConfig' => 'SiteConfig',
'LinkedPage' => 'SiteTree'
);
static $summary_fields = array(
'LinkedPage.Title' => 'Linked Page'
);
public function getCMSFields_forPopup()
{
$fields = new FieldSet();
$fields->push(new SimpleTreeDropdownField('LinkedPageID', 'Link to Internal Page'));
return $fields;
}
}
CustomSiteConfig.php
<?php
class CustomSiteConfig extends Extension {
function extraStatics() {
return array(
'has_many' => array(
'Links' => 'Link'
)
);
}
public function updateCMSFields(FieldSet &$fields) {
$manager = new DataObjectManager(
$this->owner,
'Links',
'Link',
Link::$summary_fields,
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.InfoMenu", $manager);
}
}
It all appears to work fine until you add a dataobject. It adds the object to the database and it shows up in the DOM, however the relation ID on the DO (SiteConfigID) is not set and stays 0. So for some reason all the Link Objects show up in the table, yet none of them are actually attached to the SiteConfig so when try to use them in the templates nothing is returned.
If I am honest I am not totally sure if this should work, but it would be great if it could as having a DOM in siteconfig would be really great and I assume it's not all that different to having it in Model admin which seems to work fine.
Oh one other thing I noticed, the SimpleTreeDropdown does not seem to display properly in 2.4, instead of having an indentation, it displays like:
Page
SubPage
Cheers
Aram
www.SSBits.com - SilverStripe tutorials, tips and other bits