Hi All:
I have a Dataobject set up with a nested FileDataObect. I am trying to set the default upload folder for the FileDataObject, but keep getting the error message that the "method 'setuploadfolder' does not exist on 'DataObjectManager'"
I understand why, which is because the DataObject is not a file. So I am unsure where I am supposed to note the default upload folder for the nested FileDOM. Can someone point out where it should go? I have the following snippit
$manager->setUploadFolder('SafetyAZImages');
but am guessing it has to change a bit to accommodate the nested object. Here is the code:
Thanks as always for the support!
SafetyAZPage.php
class SafetyAZPage extends Page
{
static $has_many = array (
'SafetyAZItems' => 'SafetyAZItem'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'SafetyAZItems', // Source name
'SafetyAZItem', // Source class
array('AZTitle' => 'AZTitle'), // Headings
'getCMSFields_forPopup' // Detail fields function or FieldSet
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab("Root.Content.SafetyAZItems", $manager);
return $f;
}
}
SafetyAZItem.php
<?php
class SafetyAZItem extends DataObject
{
static $db = array (
'AZTitle' => 'Text',
'AZContent' => 'Text'
);
static $has_one = array (
'SafetyAZPage' => 'SafetyAZPage'
);
static $has_many = array (
'SafetyAZImages' => 'SafetyAZImages'
);
public function getCMSFields()
{
return new FieldSet(
new TextField('AZTitle'),
new TextareaField('AZContent'),
new FileDataObjectManager(
$this,
'SafetyAZImages',
'SafetyAZImage',
'AZImage',
array('AZImageTitle' => 'AZImageTitle',
'AZImageCaption' => 'AZImageCaption')
)
);
}
}
?>
SafetyAZImage.php
<?php
class SafetyAZImage extends DataObject
{
static $db = array (
'AZImageTitle' => 'Text',
'AZImageCaption' => 'Text'
);
static $has_one = array (
'SafetyAZItem' => 'SafetyAZItem',
'AZImage' => 'File'
);
function getCMSFields()
{
return new FieldSet(
new TextField('AZImageTitle'),
new TextField('AZImageCaption'),
new FileIFrameField('AZImage')
);
}
}
?>