Coding error detected, it must be fixed by a programmer: notlocalisederrormessage

Coding error detected, it must be fixed by a programmer: notlocalisederrormessage

by Fernando Ramírez -
Number of replies: 0

Hi everybody,

I'm new in developing moodle and I have a problem that I can't solve. I'm developing a module to examinate databases exercises. I have created a form to save the script that you must introduce in mysql console to create de database. I want to add this like a text in module database for using it later. I have been looking for documentation and forums but I couldn't find anything. I put here the code. I hope somebody could help me. Thank you very much.


FORM:

/**

 * @package    mod_dbquiz

 * @copyright  2016 Your Name <your@email.address>

 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 

 */

defined('MOODLE_INTERNAL') || die();


require_once($CFG->libdir . '/formslib.php');


/**

 * Moodle form for confirming question add and get the time for the question

 * to appear on the page

 *

 *@package    mod_dbquiz

 *@copyright  2016 Your Name <your@email.address>

 *@license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

*/

class add_db_form extends moodleform {


   

    public function definition() {

        $mform = $this->_form;

 

        $mform->addElement('textarea', 'dbscript', get_string('dbscript', 'dbquiz'), 'wrap="virtual" rows="20" cols="80"');

        $mform->setType('dbscript', PARAM_TEXT);

        $mform->addRule('dbscript', null, 'required', null, 'client');

        $this->add_action_buttons();

           }    

}

VIEW:

 $toform['id'] = $id;

        $toform['courseid'] = $course;

        $toform['cm'] = $cm;

        $toform['dbquiz'] = $dbquiz;

        $mform = new add_db_form();

        $mform->set_data($toform);

        $mform->display();

        if ($mform->is_cancelled()) {

            //Handle form cancel operation, if cancel button is present on form

              print_error('invaliddata');

             $newurl = new moodle_url('/mod/dbquiz/edit.php', array('id' => $id));

             redirect($newurl,'Redirigiendo a edición...',0);

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

            //In this case you process validated data. $mform->get_datadbscript() returns data posted in form.

           print_object($fromform);

            $newurl = new moodle_url('/mod/dbquiz/view.php', array('id' => $id));

             redirect($newurl,'Redirigiendo a edición...',0);

        } 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.

            

            //Set default data (if any)

            

            //displays the form

        }


Average of ratings: -