Hi,
I'm trying to attach multiple files to a page. I'm using HasManyComplexTableField and FileIFrameField.
I get the following error on the pop-up window:
Notice: Trying to get property of non-object in C:\Projects\myproject\src\sapphire\forms\FileIFrameField.php on line 18
What am I doing wrong?
Here is my code:
<?php
class Project extends Page
{
static $db = array(
);
static $has_one = array(
);
static $has_many = array(
'ProjectAssets' => 'ProjectAsset',
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$tablefield = new HasManyComplexTableField(
$this,
'ProjectAssets',
'ProjectAsset',
array(
'FileTitle' => 'Title'
),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle('file');
$fields->addFieldToTab( 'Root.Content.Files', $tablefield );
return $fields;
}
}
class Project_Controller extends Page_Controller
{
}
?>
<?php
class ProjectAsset extends DataObject {
static $db = array(
'FileTitle' => 'Varchar(200)'
);
static $has_one = array(
'Project' => 'Project',
'File' => 'File'
);
function getCMSFields_forPopup() {
return new FieldSet(
new TextField('FileTitle', 'Title'),
new FileIFrameField('File')
);
}
}
?>