7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » SimpleTreeDropdownField value not saved
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 928 Views |
-
SimpleTreeDropdownField value not saved

8 April 2010 at 3:46am
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;
}
} -
Re: SimpleTreeDropdownField value not saved

8 April 2010 at 3:56pm
$dropdown = new SimpleTreeDropdownField('LinkToRelatedID','Link to page','SiteTree');
-
Re: SimpleTreeDropdownField value not saved

8 April 2010 at 6:42pm
Thank You very much, I knew I overlooked something
| 928 Views | ||
|
Page:
1
|
Go to Top |

