Hi, i've run in the same problem. my goal is to show some images with a redirect link on homepage.
my class:
<?php
class CustomImage extends DataObject
{
//db fields
static $db = array (
'Description' => 'Varchar(100)',
);
/**
* Our custom image class contains one image that is used on one page.
*/
public static $has_one = array (
'SliderImage' => 'Image',
'PageRedirect' => 'SiteTree'
);
/**
* Popup for editing a single image.
*
* @return FieldSet The iframe for editing the image.
*/
public function getCMSFields_forPopup(){
$fields = new FieldSet(
new TextField('Description'),
new SimpleTreeDropDownField('PageRedirectID','Bild verlinkt zu','SiteTree'),
new FileIFrameField('SliderImage','Bild für den Slider', Null, Null, Null, 'Uploads/homepage-sliderbilder/')
);
return $fields;
}
}
and my model:
class HomePage extends Page {
static $db = array(
'HomeMainHeading' => 'Text',
'HomeSubHeading' => 'Text',
'HomeCol1' => 'HTMLText',
'HomeCol2' => 'HTMLText'
);
public static $has_many = array(
'CustomImages' => 'CustomImage',
);
function getCMSFields() {
$fields = parent::getCMSFields();
//SliderImages
$images = new ImageDataObjectManager(
$this, // Controller
'CustomImages', // Source name
'CustomImage', // Source class
'SliderImage', // File name on DataObject
array(
'Description' => 'Description' //,
// 'PageRedirect' => 'PageRedirect'
), // Headings
'getCMSFields_forPopup' // Detail fields
// Filter clause
// Sort clause
// Join clause
);
...
$fields->addFieldToTab('Root.Content.SliderBilder', $images);
return $fields;
}
}
if i comment out the PageRedirect in the array there is an error (…the method 'fortemplate' does not exist on…). otherwise the SimpleTreeDropDownField is not shown in the popup. Whats wrong with this code?
Thanks for your help. Pipifix