Note:

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

Block formslib

From MoodleDocs

(This is currently a proposal and isn't available for use).


Creating a Global Configuration form

In order to create a global confuration form using formslib, you must create a file /blocks/BLOCKNAME/config_global_form.php

In this file a class like needs to be created which follows the naming scheme: block_BLOCKNAME_config_global_form.

require_once $CFG->dirroot .'/blocks/block_config_global_form.php';

class block_BLOCKNAME_config_global_form extends block_config_global_form {

    function block_configuration(&$mform){

        // add a html editor text field
        $this->add_config_element('htmleditor', 'block_BLOCKNAME_text', get_string('text','BLOCKNAME'));

        // set the default value, this will set the default value
        // or set the $CFG value for the same name, if it exists
        $this->set_config_default('block_BLOCKNAME_text', 'mydefault');

        // set an appropiate PARAM type
        $mform->setType('block_BLOCKNAME_text', PARAM_NOTAGS);

    }

}