mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-11543 Refactored editcategory and form
This commit is contained in:
parent
b7064779f5
commit
9c536df7c4
2 changed files with 68 additions and 96 deletions
|
@ -28,34 +28,9 @@ class editcategory_form extends moodleform {
|
|||
$mform->setHelpButton('description', array('writing', 'richtext'), false, 'editorhelpbutton');
|
||||
|
||||
$mform->addElement('hidden', 'id', null);
|
||||
$mform->addElement('hidden', 'categoryadd', 0);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$this->add_action_buttons(false, get_string('submit'));
|
||||
}
|
||||
|
||||
function definition_after_data() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$category = $this->_customdata['category'];
|
||||
$parentid = $this->_customdata['id'];
|
||||
|
||||
if (!empty($category->name)) {
|
||||
$id_el =& $mform->getElement('id');
|
||||
$id_el->setValue($category->id);
|
||||
$name_el =& $mform->getElement('name');
|
||||
$name_el->setValue($category->name);
|
||||
$parent_el =& $mform->getElement('parent');
|
||||
$parent_el->setValue($category->parent);
|
||||
$description_el =& $mform->getElement('description');
|
||||
$description_el->setValue($category->description);
|
||||
if (!empty($CFG->allowcategorythemes)) {
|
||||
$theme_el =& $mform->getElement('theme');
|
||||
$theme_el->setValue($category->theme);
|
||||
}
|
||||
} elseif (!is_null($parentid)) { // We assume we are adding a new category, and use $id as the parent id
|
||||
$parent_el =& $mform->getElement('parent');
|
||||
$parent_el->setValue($parentid);
|
||||
$mform->addElement('hidden', 'categoryadd', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue