I'm tearing my hair out trying to figure what I've done wrong here (if indeed I have). I just can't get a one-to-many relationship to 'stick'. I have a class, SymposiaPage which extends Page, which should have a 1-to-many relationship with a Symposium class which extends DataObject. In SymposiaPage I have this:
static $has_many = array (
'Symposia' => 'Symposium'
);
In Symposium I have this:
static $has_one = array (
'SymposiaPage' => 'SymposiaPage'
);
In SymposiaPage I also have this:
public function getCMSFields()
{
$fields = parent::getCMSFields();
$tablefield = new HasManyComplexTableField(
$this,
'Symposia',
'Symposium',
array(
'Year' => 'Year',
'Dates' => 'Dates',
'EventName' => 'Name',
'Location'=> 'Location'
),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle('Symposium');
$fields->addFieldToTab('Root.Content.Symposia', $tablefield );
return $fields;
}
This is so that I can add multiple Symposium records within a tab in the SymposiaPage record. It duly creates the Symposium records, but it doesn't establish any relationship with the SymposiaPage record, and I can't determine why. When I look in the database, it shows SymposiaPageID of 0 within the Symposium record - i.e., the real ID of the parent SymposiaPage record has not been saved in the child Symposium records, thus meaning no link has been established between parent and children (in effect they're orphans).
This is so fundamental a problem I can't believe I'm doing something stupid but I've spent hours now trying to figure out what. Any help would be most appreciated! SS 2.3.4.