Is there a way to override core Moodle forms to add more fields? like category form

245 views Asked by At

I'm trying to figure a way to add more fields to the category form in Moodle, is there a way to achieve that through local plugins? I have tried making a local plugin with the same file structure for editcategory_form.php and made a custom one with the same original file in addition to the new fields, the plugin gets recognized and installed and has it's own settings page that I can access but Moodle keeps serving me the original editcategory_form.php, how can I override it so it serves my copy of the form instead?

1

There are 1 answers

2
davosmith On BEST ANSWER

No, you cannot extend the edit category form without making core changes to the Moodle code.

With a local plugin, you could extend the navigation on the category page to include a link to a custom form (with the extra settings you want to add), but there is no way to directly override the original form (without modifying the core code).

e.g. in local/myplugin/lib.php:

function local_myplugin_extend_settings_navigation(settings_navigation $nav, context $context) {
    if ($context->contextlevel == CONTEXT_COURSECAT) {
        $nav->add(get_string('customsettings', 'local_myplugin'), new moodle_url('/local/myplugin/customsettings.php', ['categoryid' => $context->instanceid]);
    }
}

(Example code written off the top of my head,so could easily have mistakes).