Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » problems with imagedataobject_manager..

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: 332 Views
  • zim
    Community Member
    135 Posts

    problems with imagedataobject_manager.. Link to this post

    I have created an event object that stores various datatypes including two extra images... as follows


    class Event extends DataObject
       static $db = array (
          'DateStart' => 'Date',
          'DateFinish' => 'Date',
          'Name' => 'Text',
          'Time_Price' => 'Text',
          'Copy' => 'HTMLText',
          'WebLink' => 'Text',
       static $has_one = array (
          'Attachment' => 'Image',
          'Attachment2' => 'Image',
          'Attachment3' => 'Image',
          'EventsHolder' => 'EventsHolder'
       public function getCMSFields_forPopup()
          return new FieldSet(
             new DatePickerField('DateStart'),
             new DatePickerField('DateFinish'),
             new TextField('Name'),
             new TextField('Time_Price'),
             new TextareaField('Copy'),
             new TextField('WebLink'),
             new FileIFrameField('Attachment'),
             new ImageField('Attachment2'),
             new ImageField('Attachment3')


    i also have an events_holder page as follows

    * Defines the EventsHolder page type

    class EventsHolder extends Page {
    static $db = array(       

    static $has_one = array(

    static $has_many = array (
          'Events' => 'Event'

    function getCMSFields() {
        $fields = parent::getCMSFields();
        $manager = new ImageDataObjectManager(
             $this, // Controller
             'Events', // Source name
             'Event', // Source class
             'Attachment', // File name on DataObject
                'DateStart' => 'Date',
                'DateFinish' => 'Date',
                'Name' => 'Name',
                'Time_Price' => 'Time_Price',
                'Copy' => 'Copy',
                'WebLink' => 'WebLink',
                'Attachment2' => 'Attachment2',
                'Attachment3' => 'Attachment3'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
        return $fields;


    class EventsHolder_Controller extends Page_Controller {


    .... now the problem arises when i try to save the two extra images the first time I enter a new Event object.. this causes an error.. however the new event does save and when i go back to edit the event i can then enter and save the two extra images as normal.... Does this make sense and dose anyone know why this this might be happening?

    Is the imagedata0bjectmanager the best one to use for this or should i be just using filedataobjectmanager... or even just complex table field.

    any advice much appreciated

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.