Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

SimpleTreeDropdownField value not saved


Reply


3 Posts   1137 Views

Avatar
k0m0r

Community Member, 39 Posts

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;
}   
}

Avatar
UncleCheese

Forum Moderator, 4094 Posts

8 April 2010 at 3:56pm

$dropdown = new SimpleTreeDropdownField('LinkToRelatedID','Link to page','SiteTree');

Avatar
k0m0r

Community Member, 39 Posts

8 April 2010 at 6:42pm

Thank You very much, I knew I overlooked something :)