Hi..
I can't get getComponents() to behave. Can somebody spot the problem ?
The class VestigingenPage has many FaciliteitTijdstip. FacilitijdTijdstip has just one Vestigingenpage. The relationship works. I can add rows to the database and the Foreigh key to Vestigingenpage gets stored properly.
I'd like to limit the list of the FaciliteitTijdstip so it only shows the entry's which are linked to the current Vestiging (Foreign key in the database is called VestigingID).
No matter what value I give the VestigingID in the GetComponents() call. It just does not limit the list and shows all records.
HELP !!! ;-)
Class FaciliteitTijdstip:
class FaciliteitTijdstip extends DataObject {
static $db = array(
'Value1' => "Text",
'Value2' => "Text"
);
static $has_one = array(
'Vestiging' => 'VestigingenPage'
);
...
Class VestigingsPage:
class VestigingenPage extends Page {
static $has_many = array(
'FaciliteitTijdstippen' => 'FaciliteitTijdstip',
);
function FaciliteitTijdstippenFiltered() {
return $this->getComponents("FaciliteitTijdstippen", "VestigingID=$this->ID");
}
function getCMSFields() {
$fields = parent::getCMSFields();
$tablefield = new HasManyComplexTableField(
$this,
'FaciliteitTijdstippenFiltered',
'FaciliteitTijdstip',
array(
'Value1' => 'FirstName',
'Value2' => 'Family Name',
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab( 'Root.Content.Tijdschema', $tablefield );
return $fields;
}
...