conceptual misunderstanding

conceptual misunderstanding

by Daniele Cordella -
Number of replies: 2
Picture of Core developers Picture of Plugin developers
I am developing a new module.
Each time I reload the module page I have to pass through a GET the parameters $id and $cm otherwise the view.php doesn't let me get in.

I want to add a form into my view.php
I want to use moodle forms.
I enter a standard form with just one filed (following the instruction found in http://docs.moodle.org/en/Category:Formslib). The simpler you like, for instance (to let you understand):

<?php
require_once ($CFG->dirroot.'/lib/formslib.php');

class mod_studing_entry_form extends moodleform {
function definition() {
$mform =& $this->_form;
// edit field: dogname
$mform->addElement('text', 'dogname', get_string('dogname_label', 'studing'), null);
$mform->addRule('dogname', get_string('required'), 'required', null, 'client');
$this->add_action_buttons($cancel = true, $submitlabel=null);
}
}

Now I push the submit (or the cancel) button and... the form sends data through a POST so... the view.php page doesn't reload but shows the standard error: "Course module is incorrect"

How can I solve the problem?
Thank you in advance.
Average of ratings: -
In reply to Daniele Cordella

Re: conceptual misunderstanding

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
When you create your mod_studing_entry_form, you can pass the $action URL as the first parameter to the constructor, and you can use a URL that is $CFG->wwwroot.'/mod/mymod/view.php?id='.$myid
with whatever parameters you need.
In reply to Tim Hunt

Re: conceptual misunderstanding

by Daniele Cordella -
Picture of Core developers Picture of Plugin developers
Fantastic. In these forums if a user already has the information he/she needs or if he/she asks for it, it is the same. He/She can proceed in just a clock tick.
Thank you Tim.