2
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
3
class editcategory_form extends moodleform {
6
function definition() {
8
$mform =& $this->_form;
9
$category = $this->_customdata;
11
// get list of categories to use as parents, with site as the first one
12
$options = array(get_string('top'));
15
// Editing an existing category.
16
make_categories_list($options, $parents, 'moodle/category:manage', $category->id);
17
$strsubmit = get_string('savechanges');
19
// Making a new category
20
make_categories_list($options, $parents, 'moodle/category:manage');
21
$strsubmit = get_string('createcategory');
24
$mform->addElement('select', 'parent', get_string('parentcategory'), $options);
25
$mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30'));
26
$mform->addRule('name', get_string('required'), 'required', null);
27
$mform->addElement('htmleditor', 'description', get_string('description'));
28
$mform->setType('description', PARAM_RAW);
29
if (!empty($CFG->allowcategorythemes)) {
31
$themes[''] = get_string('forceno');
32
$themes += get_list_of_themes();
33
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
35
$mform->setHelpButton('description', array('writing', 'richtext'), false, 'editorhelpbutton');
37
$mform->addElement('hidden', 'id', 0);
38
$mform->setType('id', PARAM_INT);
39
$mform->setDefault('id', $category->id);
41
$this->add_action_buttons(true, $strsubmit);