Hello,
I am updating website for a festival, and I want to use page ProgramDay.php to store several concerts Concert.php as Dataobject.
It is obvious that ProgramDay 1 has different concerts than ProgramDay 2
My problem is that same concerts appear on EACH ProgramDay page, when I add concerts to ProgramDay 1, they appear also on Program Day 2..
Website is built with SS 2.2.2
Please help? Thanks in advance
Concert.php
<?php
class Concert extends DataObject {
static $db = array (
'Title' => 'Text',
'Place' => 'Text',
);
static $has_one = array (
'ProgramDay' => 'ProgramDay'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Title', 'Concert title' ) );
$fields->push( new TextField( 'Place' ) );
return $fields;
}
}
?>
ProgramDay.php
<?php
class ProgramDay extends Page {
static $has_many = array (
'Concerts' => 'Concert'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$tablefield = new ComplexTableField(
$this, 'Concerts', 'Concert',
array( 'Title' => 'Title', 'Place' => 'Place'), 'getCMSFields_forPopup' );
$tablefield->setParentClass('ProgramDay');
$fields->addFieldToTab( 'Root.Content.Concerts', $tablefield );
return $fields;
}
}
class ProgramDay_Controller extends Page_Controller {
function Siblings() {
$whereStatement = "ParentID = ".$this->ParentID;
return DataObject::get("Page", $whereStatement);
}
}
?>