General developer forum

Displaying a moodleForm after installation

Picture of Tobias G
Displaying a moodleForm after installation

Hello everybody,
I'd like to display a moodleform right after installation. So far, I've tried to do that in xmldb_auth_mypluginname_install() like this:

function xmldb_auth_mypluginname_install() {
global $CFG;
global $OUTPUT;
require_once $CFG->dirroot . '/auth/mypluginname/classes/forms.php';
require_once $CFG->dirroot . '/auth/mypluginname/locallib.php';
$mform = new myform();

//Form processing and displaying is done here
if ($mform->is_cancelled()) {
//Handle form cancel operation, if cancel button is present on form

} else if ($fromform = $mform->get_data()) {
//In this case you process validated data. $mform->get_data() returns data posted in form.
} else {
// this branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
// or on the first display of the form.

The form gets displayed properly, but do_something is never actually called, when the save button is clicked. Instead, the normal upgrade process just continues.

I'd guess the reason why it doesn't work is because it's displayed within a function and not a script, because it works fine, whenever I use it in a script.

How can I display and evaluate this form without having to redirect to another php script and thereby interrupting the upgrade process?
It would be amazing, if anyone of you could help me.

Edit: My formatting of the code snippet did not work and I've no idea how to fix it. Sorry for that.

Average of ratings: -