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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

[solved] Displaying current value of TreeDropDown


Go to End


2 Posts   2123 Views

Avatar
netnoise

Community Member, 10 Posts

10 February 2010 at 11:20pm

Edited: 11/02/2010 1:13am

How can I make the TreeDropDownField to display the currently selected item upon page load? It says "Choose..." even though a value for the field is set.

$tree = new TreeDropdownField('MyFile', 'Selected File', 'File', 'ID');
$tree->setTreeBaseID(3);
  
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', $tree, 'Content');

Am I missing something or is there any workaround?

Avatar
netnoise

Community Member, 10 Posts

11 February 2010 at 1:13am

Edited: 11/02/2010 1:14am

My code was wrong. The field name MyFileID must be used instead of MyFile:

$tree = new TreeDropdownField('MyFileID', 'SelectedFile', 'File', 'ID');