I want to display course list in moodle form and using following code;

```
$options = array();
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
foreach ($allcourses as $course) {
    $options[$course->id] = $course-fullname;
}
$mform->addElement('select', 'courseid', get_string('course'), $options);
$mform->setDefault('courseid', $currentcourseid);
$mform->setType(PARAM_INT);

```

But it displays error at `$allcourses = coursecat::get(0)->get_courses(array('recursive' = true);` any guidance or help?

Thanks
Regards