I am developing a site which holds classroom courses that members can book onto. Courses are added/updated through a ModelAdmin class in the back end. The client has requested a 'Duplicate' button within the ModelAdmin because they often need to add courses with almost identical information to a course that already exists.
Following other forum posts on here, I added a 'duplicate' button within the ModelAdmin_RecordController that sits next to the 'Back', 'Delete' & 'Save' button. I just can't get it to do anything i.e. doDuplicate isn't getting called. This is code for my ModelAdmin:
<?php
class BookingAdmin extends ModelAdmin {
static $managed_models = array(
'Course',
'Booking'
);
static $url_segment = 'Bookings';
static $menu_title = 'Courses & Bookings';
public static $record_controller_class = "BookingAdmin_RecordController";
}
class BookingAdmin_RecordController extends ModelAdmin_RecordController {
public function doDuplicate($data, $form, $request) {
//do something
}
}
?>
And my Course class contains the following:
class Course extends DataObject {
...
function getCMSActions(){
$actions = parent::getCMSActions();
$Action = new FormAction(
"doDuplicate",
"Duplicate Course"
);
$actions->push($Action);
return $actions;
}
...
}
What am i missing? Many thanks in advance.