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, Ed, biapar, Willr, Ingo, swaiba

Nested DOMs setUploadFolder

Go to End

2 Posts   561 Views


Community Member, 33 Posts

7 March 2012 at 3:40pm

A few questions re: nested DataObjectManager.

1) I'm trying to setUploadFolder for nested DOMs. The code below is not working. Files are uploaded to "Uploads".

2) Though the Images are near their respective Alt Text fields in the CourseAdvertisement->getCMSFields_forPopup() FieldSet, they don't appear nearby in the popup window. Also the setUploadFolder in CourseSalesPage->getCMSFields() doesn't seem to have any effect. Images are also uploaded to 'Uploads'.

3) How do I specify field types? The specification in the CourseAdvertisement->getCMSFields_forPopup() FieldSet don't seem to have any effect. If I try to add them in an array in the CourseSalesPage DataObjectManager instantiation, or call getCMSFields_forPopup there, the admin throws errors.

class CourseAdvertisement extends DataObject {
    public static $db = array (
        'CourseName' => 'Text',
        'CourseDescription'=> 'HTMLText',
        'CourseBuyNowButtonCode' => 'HTMLText',
        'CourseMainImageAltText' => 'Text',
        'CourseSmallImageAltText' => 'Text',
        'CourseAdditionalDescription' => 'HTMLText'
    static $has_one = array (
        'CourseMainImage' => 'Image',
        'CourseSmallImage' => 'Image',
        'CourseSalesPage' => 'CourseSalesPage'
    static $has_many = array (
        'Files' =>'CourseAdvertisementFile'
    public function getCMSFields_forPopup() {
        $files = new FileDataObjectManager (
                    'FileName' => 'Name',
                    'FileDescription' => 'Description'
		$files->allowUploadFolderSelection = false;
        return new FieldSet(
            new TextField('CourseName', 'Course Name'),
            new SimpleHTMLEditorFieldField('CourseDescription', 'Course Description'),
            new TextField('CourseBuyNowButtonCode', 'Buy Now Button Code'),
            new ImageField('CourseMainImage', 'Main Image'),
            new TextField('CourseMainImageAltText', 'Alternate Text for Main Image'),
            new ImageField('CourseSmallImage', 'Small Image'),
            new TextField('CourseSmallImageAltText', 'Alternate Text for Small Image'),
            new TextField('CourseAdditionalDescription', 'Additional Description (below small image on right)'),
class CourseSalesPage extends Page {
	public static $allowed_actions = array (

	public static $db = array(
	public static $has_one = array(
	public static $has_many = array(
		'CourseAdvertisements' => 'CourseAdvertisement'	
	function getCMSFields() {
		$fields = parent::getCMSFields();
		//drag and drop-ability is set in mysite/_config.php sortable
		$courses = new ImageDataObjectManager (
		$courses->allowUploadFolderSelection = false;
		$fields->addFieldToTab('Root.Content.Courses', $courses);

		return $fields;



Community Member, 33 Posts

8 March 2012 at 2:57pm

After watching the nested DOM screencast for the 10th time, I saw that in getCMSFields_forPopup in the code below should be getCMSFields.

This tutorial specifies that getCMSFields, not getCMSFields_forPopup should be used -

With that change this mostly works as expected, after correcting the typo in SimpleHTMLEditorField.