Here is my DOM:
class VideoHolder extends Page {
static $has_many = array(
'VideoObjects' => 'VideoObject'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$datamanager = new DataObjectManager(
$this, // Controller
'VideoObjects', // Source name
'VideoObject', // Source class
array(
'Category' => 'Category',
'Description' => 'Description',
'YouTubeLink' => 'YouTubeLink',
'URLSegment' => 'URLSegment'
), // Headings
'getCMSFields_forPopup'// Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
//$datamanager->setPopupWidth('675');
$fields->addFieldToTab("Root.Content.Videos",$datamanager);
return $fields;
}
}
and my DataObject:
class VideoObject extends DataObject {
static $db = array (
'Category' => "Enum('Auto Load and Unload, Cappers, DeCappers, Fillers, Leak Detection, Robotics, Washers', 'Auto Load and Unload')",
'Description' => 'Varchar(255)',
'YouTubeLink' => 'Varchar(255)',
'ShortCode' => 'HTMLText',
'URLSegment' => 'Varchar(255)'
);
static $has_one = array(
'VideoHolder' => 'VideoHolder'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new DropdownField(
$name = "Category",
$title = "Video Category",
$source = singleton('VideoObject')->dbObject('Category')->enumValues()
),
new TextField('Description','Description (text appears in link)'),
new TextField('YouTubeLink','URL of YouTube Page')
);
}
public function onBeforeWrite()
{
if($this->Description){
$this->URLSegment = SiteTree::GenerateURLSegment($this->Description);
if($object = DataObject::get_one($this->ClassName, "URLSegment='" .$this->URLSegment
."' AND ID !=".$this->ID)){
$this->URLSegment = $this->URLSegment.'-'.$this->ID;
}
// else {
//$this->URLSegment = SiteTree::GenerateURLSegment($this->ClassName.'-'.$this->ID);
//}
}
if($this->YouTubeLink){
$this->ShortCode = '[YouTube id="'.substr($this->YouTubeLink,strpos($this->YouTubeLink,"watch?v=")+8,strlen($this->YouTubeLink)).'"]';
}
parent::onBeforeWrite();
}
function ShowActionLink(){
if($this->VideoHolder()){
return $this->VideoHolder()->Link().'show/'.$this->URLSegment;
}
}
}
If the environment type is 'dev' I get a notice in the popup:
[Notice] Undefined index: start
GET /admin/EditForm/field/VideoObjects/item/1?SecurityID=11197/edit?ctf[VideoObjects][start]=0&ctf[VideoObjects][per_page]=10&ctf[VideoObjects][showall]=0&ctf[VideoObjects][sort]=&ctf[VideoObjects][sort_dir]=&ctf[VideoObjects][search]=&ctf[VideoObjects][filter]=
Line 139 in C:\website\cs\dataobject_manager\code\DataObjectManager.php
If environment type is not 'dev' I get the pop up, but the fields are not editable.
TIA
Luke