I'm trying to add some data fields to a course by creating a custom course format. This approach was recommended in a forum post and so far I've had success adding select and text fields, however one of the fields I'm adding needs to be an uploaded image. Since I want to be able to exit/view the image I'm trying to implement that using a filemanager. The problem I am having is understanding where to do the setup of the filemanager.
In creating my custom format, I've copied the existing topics format and modified the course_format_options method to include an entry for the filemanager- just like I did for the new select and text fields we have added that are working- but what I don't understand is where I should be calling the setup function referenced in the example in Using the File API
$entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $context,
'mod_glossary', 'attachment', $entry->id);
I can get the form element to appear when I access the course edit page, but clearly without file_prepare_... it's not connected to anything.
Looking through the code for other examples using the filemanager- specifically in course/edit.php and course/edit_form.php- I see the file_prepare_standard_filemanager method being called prior to creating the form, but since the form already exists by the time my custom format's methods are called I'm not sure how to accomplish this.
Has any one had success implementing the filemanager input in a custom course format? This is my first foray into Moodle so I'm excited to get to know this system.