Hi there.
I encountered a following problem with SimpleTreeDropdownField.
I have a following structure:
1. FaqList page with collection of FaqItem data objects (managed by DOM).
2. Each FaqItem may contain many RelatedItem data objects (managed by DOM in pop-up - this works fine).
3. Each RelatedItem pop-up has a SimpleTreeDropdownField.
Now, when I create a new FaqItem, save it, and then add a RelatedItem, everything works fine.
I can save and display (in CMS and online) all the values except for the 'LinkToRelated' field.
The SimpleTreeDropdownField value simply isn't saved.
Even in CMS, after saving the RelatedItem popup - I can see that the select value goes back to the empty line ('select a page').
Any idea what's wrong?
Here is a piece of code:
class FaqList extends Page {
public static $db = array(
);
public static $has_many = array(
"Items" => "FaqItem",
);
function getCMSFields() {
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this,
'Items',
'FaqItem',
array('Title' => 'Title'),
'getCMSFields_forPopup'
);
$fields->addFieldToTab('Root.Content.Items',$manager);
return $fields;
}
}
class FaqItem extends DataObject {
public static $db = array(
);
public static $has_one = array(
"FaqList" => "FaqList",
);
public static $has_many = array(
"RelatedItems" => "RelatedItem",
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$manager = new DataObjectManager(
$this,
'RelatedItems',
'RelatedItem',
array('Title' => 'Title'),
'getCMSFields_forPopup'
);
$fields->push($manager);
return $fields;
}
}
class RelatedItem extends DataObject {
public static $db = array(
);
public static $has_one = array(
"ItemParent" => "DataObject",
"LinkToRelated" => "SiteTree",
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$dropdown = new SimpleTreeDropdownField('LinkToRelated','Link to page','SiteTree');
$dropdown->setEmptyString('-- Select a page --');
$fields->push($dropdown);
return $fields;
}
}