Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Nested DOMs setUploadFolder

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 322 Views
  • cmc
    Community Member
    23 Posts

    Nested DOMs setUploadFolder Link to this post

    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;


  • cmc
    Community Member
    23 Posts

    Re: Nested DOMs setUploadFolder Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.