Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Problem while uploading multiple images

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: 595 Views
  • neerom
    Avatar
    Community Member
    8 Posts

    Problem while uploading multiple images Link to this post

    Hi,
    I am trying to upload multiple photos with a caption.
    But after adding caption for all the uploaded pictures, when i click 'finish' button, it does not come back to the page it started from.

    Please help..

    Homepage.php:
    <?php
    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {
    static $db = array(
        'Description' => 'Text'
       
    );
    static $has_one = array(
        'ProfileImage' => 'CustomImage'
    );
       
       public static $has_many = array(
    'AttachedFiles' => 'SlideShow',
          'AttachedPhotos' => 'PhotoStream',   
          'HolidayPictures' => 'HolidayPicture'

    );

    public function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Main', new FileUploadField('ProfileImage', 'Upload a profile image'));
          
          /* Add the code below this line */
          // This adds a DataObjectManager to a new tab
          $manager = new ImageDataObjectManager(
             $this,
             'HolidayPictures',
             'HolidayPicture',
             'Attachment',
             array(
                'Caption' => 'Caption'
             ),
             'getCMSFields_forPopup'
          );
          $fields->addFieldToTab("Root.Content.HolidayPictures", $manager);
          

          
    return $fields;
    }

    }

    class HomePage_Controller extends Page_Controller {
       
    public function init()
       {
    parent::init();

    }

       
       

    }

    and HolidayPictures.php:

    <?php
    class HolidayPicture extends DataObject
    {
       static $db = array (
          'Caption' => 'Text'
       );
       
       static $has_one = array (
          'Attachment' => 'CustomImage',
          'EmployeePage' => 'EmployeePage'
          
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new FileUploadField('Attachment', 'Add a holiday picture'),
             new TextAreaField('Caption', 'Add a caption')
          );
       }
    }

    595 Views
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.