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.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

TreeDropDownField/DropDownField in DataObject does not save related SiteTree

Go to End

5 Posts   3230 Views


Community Member, 80 Posts

8 May 2013 at 2:36am

Edited: 08/05/2013 2:36am

I just tested on a blank 3.0.5 installation and 3.1 beta 3.
If you have have a DataObject with related SiteTree like this...

    private static $has_one = array(
        "MySiteTree" => "SiteTree"

editing the DataObject... the DropDownField never remembers the selected Page. the same happens with TreeDropDownField.
It looks like it´s always saving the SiteTreeID of the Page that you are just editing in the CMS.

Is there any solution to this? or is it just a bug?


Community Member, 94 Posts

17 May 2013 at 6:36pm

I'm having this experience too, with a days-old pull down of the 3.1 branch. Any chance you found an answer or a patch for this spierala? Cheers.


Community Member, 58 Posts

27 May 2013 at 11:07pm

Edited: 27/05/2013 11:07pm

If I understand correctly...

public function getCMSFields() {
        $fields = parent::getCMSFields();

        $obiect = Obiect::get()->map('ID', 'Title');

        $fields->addFieldToTab("Root.Main", new DropdownField('ObiectID', 'Płatność za', $obiect));

        return $fields;

Sorry for my bad English


Community Member, 70 Posts

15 January 2014 at 1:18pm

Did you ever get a solution for this for the TreeDropdownField - I'm getting the same issue


Community Member, 244 Posts

2 April 2015 at 12:26am

after trying for a while on this one just now, i remembered that although you name the has_one as something like 'MyPageLink', the tree dropdown field needs to have the name 'MyPageLinkID' added


private static $has_one = array(
		'Link1' => 'SiteTree',		
$fields->addFieldToTab('Root.Link', new TreeDropdownField("Link1ID", "Page to link to", "SiteTree"));