General developer forum

Minimum source for simple form

Picture of Andreas Duerr
Minimum source for simple form


I'm new in developing plugins for Moodle and I'm stumpling up on the most easy problem. I tried to use the simple form api. The easiest thing was just the follwing code in my view.php

$mform = new mod_subrooms_mod_form();


My form definition looks like this:

class mod_subrooms_mod_form extends moodleform {

public function definition() {

  global $CFG;

  $mform = $this->_form;




In Moodle I can see my submit button, but when I push it I just get an error message ("Coding error detected, it must be fixed by a programmer: notlocalisederrormessage").

I filled up the source code in my view.php with the surrounding 

if ($mform->is_cancelled()) {

} else if ($mreturn=$mform->get_data()) {

} else {



No effect, I added rules, the validation function in my form-class - again no effect.

I looked to other plugins but I can find no significant difference.

My question is, what is the minimum code not to get an error message while using the simple form api?

Thanks for helping,


Average of ratings: -