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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Hidden SimpleTreeDropdownField in 2.4 / r395


Go to End


5 Posts   2004 Views

Avatar
silverstriper

Community Member, 8 Posts

7 May 2010 at 1:05am

I'm having difficulty with the SimpleTreeDropdownField in Silverstripe 2.4 Final and release 395 of DataObjectManager module - it simply doesnt' show.

Any clues?

All other fields show, but not that one.

It doesn't appear at first glance to be the same as the problem with the SimpleHTMLEditorField described here where the class hidden wasn't being unset by the JavaScript http://www.silverstripe.org/dataobjectmanager-module-forum/show/283202 as the HTML code isn't even being output to the popup window.

Below is the code for my data object that does this in case it helps:

<?php
	class HCPFeature extends DataObject {
		//database
		public static $db = array(
			"Title" => "Varchar(255)",
			"Description" => "HTMLText"
		);
		
		public static $has_one = array(
			"HeroImage" => "HCPFeature_Image",
			"DeepLink" => "SiteTree"
		);
			
		public function getCMSFields() {
			$fields = new FieldSet();
			$fields->push( new TextField( 'Title', 'Title' ) );
			$fields->push( new SimpleHTMLEditorField( 'Description', 'Description' ) );
			$fields->push( new SimpleTreeDropdownField("DeepLinkID", "Links to page", "SiteTree") );
			$fields->push( new ImageField( 'HeroImage', 'Image' ) );
			
			return $fields;
		}
	}
	
	class HCPFeature_Image extends Image {
		function generateHeroLarge($gd) {
			$gd->setQuality(100);
			return $gd->paddedResize(468,220);
		}
	}
?>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

7 May 2010 at 2:32am

It almost always happens because you already have that field added to your form. Check the markup and see if there's maybe a hidden input for DeepLinkID. Try changing it to something else and you'll notice it gets added.

Avatar
silverstriper

Community Member, 8 Posts

18 May 2010 at 12:22am

Unfortunately renaming this field did not fix the problem. It simply does not output no matter what it is called.

I've tried removing all other fields on the popup form to see if there was a conflict problem, but still no joy.

Can you help please?

Avatar
silverstriper

Community Member, 8 Posts

18 May 2010 at 8:58pm

Ok I have fixed this problem!

It was caused by having the relationAutoSetting enabled on my page, but no field for the relationship defined on my DataObject, so it was trying to use the "SiteTree" field that I wanted for the SimpleTreeDropdownField for the relationship instead and causing conflict.

Adding a new field for the relationship on my DataObject solved this problem.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

19 May 2010 at 1:24am

Oh, excellent. We definitely need to document this. Good work!