Hi. Was hopeing for a bit of help. Can't understand this one.
on page Speakers.php is have the code:
class Speakers extends DataObject {
static $db = array(
'FirstName' => 'Text',
'LastName' => 'Text',
'Position' => 'Text',
'Company' => 'Text',
);
public static $has_one = array(
'Speaker' => 'SpeakersPage',
'SpeakerImage' => 'Image',
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'FirstName', 'First Name' ) );
$fields->push( new TextField( 'LastName' ) );
$fields->push( new TextField( 'Position' ) );
$fields->push( new TextField( 'Company' ) );
$fields->push( new ImageField('SpeakerImage') );
return $fields;
}
...
and on SpeakersPage.php
<?php
class SpeakersPage extends SiteTree {
public static $db = array(
'RightContent' => 'HTMLText',
);
public static $has_one = array(
);
public static $has_many = array(
'MySpeakers' => 'Speakers',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$tablefield = new HasManyDataObjectManager(
$this,
'MySpeakers',
'Speakers',
array(
'FirstName' => 'First Name',
'LastName' => 'Family Name',
'Position' => 'Position',
'Company' => 'Company',
'SpeakerImage' => 'Speaker Image',
),
'getCMSFields_forPopup'
);
$tablefield->setParentClass('Speakers');
$fields->addFieldToTab( 'Root.Content.Speakers', $tablefield );
This doesn't work? If I use the class 'DataObjectManager' it is fine. Of course, I would like to be able to use the HasManyDataObjectManager as each Speaker page will display different speakers. Can you point me as to where I'm going wrong here?
Thanks