This is more or less an extension on this forum discussion: http://www.silverstripe.com/site-builders-forum/flat/150429
I'm at the point where my dropdown list populates w/ the correct info, but it doesn't save to the database. Basically, I am setting up the following pages: Degrees, which have courses, which have course types. The degrees are a pagetype and courses and course types are data objects. Here is my code for the Course.php data object:
<?php
class Course extends DataObject {
static $db = array(
'CourseTitle' => 'Text',
'CourseDescription' => 'Text',
'CreditHours' => 'Decimal',
'PreRequisites' => 'Text',
'MyCourseTypeID' => 'Decimal',
'CourseType' => 'Text',
);
static $has_one = array(
'MyCourseTypes' => 'CourseTypes'
);
static $belongs_many_many = array(
'Degrees' => 'Degree'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'CourseTitle' ) );
$fields->push( new TextAreaField( 'CourseDescription', 'Description' ) );
$fields->push( new NumericField( 'CreditHours' ) );
$fields->push( new TextField( 'PreRequisites' ) );
$ctype = DataObject::get("MyCourseTypes");
$map = $ctype->toDropDownMap('ID', 'CourseType');
$fields->push( new DropdownField(
'MyCourseTypeID',
'CourseType',
$map)
);
return $fields;
}
}
?>
Any help you could give me would be very appreciated.