OK, I have the following dataobject:
<?php
class TestObject extends DataObject {
static $db = array(
);
static $has_one = array(
'FileName' => 'Image'
);
static $belongs_many_many = array(
'TestPages' => 'TestPage'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new ImageField( 'FileName', 'ColorImage' ) );
return $fields;
}
}
?>
And then I have the following code in TestPage.php:
static $many_many = array(
'TestObjects' => 'TestObject'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$testTablefield = new ManyManyComplexTableField(
$this,
'TestObjects',
'TestObject',
array(
'FileNameID' => 'File'
),
'getCMSFields_forPopup'
);
$testTablefield->setPageSize(100);
$testTablefield->setAddTitle( 'a TestObject' );
$fields->addFieldToTab( 'Root.Content.TestObjects', $testTablefield );
return $fields;
}
Everything works, saves, etc. But: in the many-many table in the TestObjects tab, the FileName shows up as an ID. If I remove the "ID" from FileName, I get a server error. How can I show the name of the file, or the url, in the many-many table?
Thanks!