Note:

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

Block formslib: Difference between revisions

From MoodleDocs
No edit summary
 
Line 6: Line 6:
In order to create a global confuration form using formslib, you must create a file <span class="filename">/blocks/BLOCKNAME/config_global_form.php</span>
In order to create a global confuration form using formslib, you must create a file <span class="filename">/blocks/BLOCKNAME/config_global_form.php</span>


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


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


Line 27: Line 28:


}
}
</pre>

Revision as of 19:50, 29 April 2007

(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);

    }

}