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')
);
}
}