Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Talk:Form API

From MoodleDocs
Revision as of 11:28, 2 April 2018 by eric M (talk | contribs) (→‎Usage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Usage

This section says: "For creating a form in moodle, you have to create class extending moodleform class", but WHERE do you create this class? Which .php file? Is it simplehtml_form.php?

Below the "class simplehtml_form extends moodleform" sample code the doc then says: "Then instantiate form (in this case simplehtml_form) on your page." Where do you instantiate the form? In the view.php page?

Lastly, where do you put the code that processes and saves the form data when the form is submitted?

The documentation should be clear about where you should put all the different sections of code.

As Well, When I'm trying to test the example, i have a error mesage: Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result