I want to restrict the list of objects provided when editing a data item with a one to one relationship to another object, who's parent has a one to many relationship to an object also with a one to one relationship with the original object....
Customer has many Jobs
Customer has many Sites
Job has one Customer
Job has one Site (this should be restricted to only those under Customer)
Site has one Customer
Site has many Jobs
class Customer extends DataObject {
public static $has_many = array(
'Sites' => 'Site',
'Jobs' => 'Job'
);
}
class Job extends DataObject {
public static $has_one = array(
'Site' => 'Site',
'Customer' => 'Customer'
);
}
class Site extends DataObject {
public static $has_one = array(
'Customer' => 'Customer'
);
public static $has_many = array(
'Jobs' => 'Job'
);
}
How do I make the list of Sites available to Job be restricted to only those Sites related to the Job's Customer?