I’m modelling a very basic association between courses (CoursePage) and instances of that course (CourseInstance extending from DataObject):
class CoursePage extends Page {
public static $has_many = array('Instances' => 'CourseInstance');
}
class CourseInstance extends DataObject {
public static $has_one = array('Course' => 'CoursePage');
}
What I want in the CMS is a simple way to add course instances to the course page. The HasManyComplexDataField is working but means that all course pages have the same (long!) list of instances shared across all courses. What I want is a way to add / remove / edit just instances relating to that course, without any details of instances from any other CoursePage.
Is there a more simple field more suited to my needs? Alternatively, is there any way I can limit the complex field to only show related instances but also allow me to add new ones?
Setting the
sourceFilterparameter of theHasManyComplexDataFieldto the following works: