added new 'cancel' element type and introduced new is_cancelled() MoodleQuickForm method.

also used new cancel button in all mod_forms as well as a 'Revert' button and reworked logic about where to go on cancel or after submission for modedit.php
This commit is contained in:
jamiesensei 2006-12-04 09:36:30 +00:00
parent 9c0f063b2c
commit 19110c573d
17 changed files with 174 additions and 128 deletions

View File

@ -45,10 +45,11 @@
if (!empty($add)){ if (!empty($add)){
$modname=$add; $modname=$add;
if (file_exists("../mod/$modname/mod_form.php")) { if (file_exists("../mod/$modname/mod_form.php")) {
$id = required_param('id',PARAM_INT); $id = required_param('id', PARAM_INT);
$section = required_param('section',PARAM_INT); $section = required_param('section', PARAM_INT);
$returntomod = optional_param('return', PARAM_BOOL);
redirect("modedit.php?add=$add&course=$id&section=$section"); redirect("modedit.php?add=$add&course=$id&section=$section&return=$returntomod");
} }
}elseif (!empty($update)){ }elseif (!empty($update)){
if (!$modname=get_field_sql("SELECT md.name if (!$modname=get_field_sql("SELECT md.name
@ -58,8 +59,9 @@
md.id = cm.module")){ md.id = cm.module")){
error('Invalid course module id!'); error('Invalid course module id!');
} }
$returntomod = optional_param('return', PARAM_BOOL);
if (file_exists("../mod/$modname/mod_form.php")) { if (file_exists("../mod/$modname/mod_form.php")) {
redirect("modedit.php?update=$update"); redirect("modedit.php?update=$update&return=$returntomod");
} }
} }
//not adding / editing a module that has new forms using formslib //not adding / editing a module that has new forms using formslib

View File

@ -9,22 +9,8 @@
$add = optional_param('add', '', PARAM_ALPHA); $add = optional_param('add', '', PARAM_ALPHA);
$update = optional_param('update', 0, PARAM_INT); $update = optional_param('update', 0, PARAM_INT);
//return to course/view.php if false or mod/modname/view.php if true
$cancel = optional_param('cancel', 0, PARAM_BOOL); $return = optional_param('return', 0, PARAM_BOOL);
if ($cancel) {
if (!empty($SESSION->returnpage)) {
$return = $SESSION->returnpage;
unset($SESSION->returnpage);
redirect($return);
} else {
$course = required_param('course', PARAM_INT);
$section = optional_param('section', '', PARAM_INT);
if (! $course = get_record("course", "id", $course)) {
error("This course doesn't exist");
}
redirect("view.php?id=$course->id#section-$section");
}
}
if (!empty($add)){ if (!empty($add)){
$section = required_param('section', PARAM_INT); $section = required_param('section', PARAM_INT);
@ -54,6 +40,7 @@
$form->instance = ""; $form->instance = "";
$form->coursemodule = ""; $form->coursemodule = "";
$form->add=$add; $form->add=$add;
$form->return=0;//must be false if this is an add, go back to course view
if (!empty($type)) { if (!empty($type)) {
$form->type = $type; $form->type = $type;
} }
@ -102,7 +89,8 @@
$form->module = $module->id; $form->module = $module->id;
$form->modulename = $module->name; $form->modulename = $module->name;
$form->instance = $cm->instance; $form->instance = $cm->instance;
$form->update=$update; $form->return = $return;
$form->update = $update;
$sectionname = get_string("name$course->format"); $sectionname = get_string("name$course->format");
$fullmodulename = get_string("modulename", $module->name); $fullmodulename = get_string("modulename", $module->name);
@ -135,9 +123,16 @@
} }
$mformclassname=$module->name.'_mod_form'; $mformclassname=$module->name.'_mod_form';
$mform=& new $mformclassname($form->instance, isset($cw->section)?$cw->section:$section, ((isset($cm))?$cm:null)); $cousesection=isset($cw->section)?$cw->section:$section;
$mform=& new $mformclassname($form->instance, $cousesection, ((isset($cm))?$cm:null));
if ($fromform=$mform->data_submitted()){ if ($mform->is_cancelled()) {
if ($return && isset($cm)){
redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id");
} else {
redirect("view.php?id=$course->id#section-".$cousesection);
}
} elseif ($fromform=$mform->data_submitted()){
if (empty($fromform->coursemodule)) { //add if (empty($fromform->coursemodule)) { //add
if (! $course = get_record("course", "id", $fromform->course)) { if (! $course = get_record("course", "id", $fromform->course)) {
error("This course doesn't exist"); error("This course doesn't exist");
@ -175,12 +170,12 @@
} }
} }
$return = $updateinstancefunction($fromform); $returnfromfunc = $updateinstancefunction($fromform);
if (!$return) { if (!$returnfromfunc) {
error("Could not update the $fromform->modulename", "view.php?id=$course->id"); error("Could not update the $fromform->modulename", "view.php?id=$course->id");
} }
if (is_string($return)) { if (is_string($returnfromfunc)) {
error($return, "view.php?id=$course->id"); error($returnfromfunc, "view.php?id=$course->id");
} }
if (isset($fromform->visible)) { if (isset($fromform->visible)) {
@ -191,11 +186,6 @@
set_coursemodule_groupmode($fromform->coursemodule, $fromform->groupmode); set_coursemodule_groupmode($fromform->coursemodule, $fromform->groupmode);
} }
if (isset($fromform->redirect)) {
$SESSION->returnpage = $fromform->redirecturl;
} else {
$SESSION->returnpage = "$CFG->wwwroot/mod/$fromform->modulename/view.php?id=$fromform->coursemodule";
}
add_to_log($course->id, "course", "update mod", add_to_log($course->id, "course", "update mod",
"../mod/$fromform->modulename/view.php?id=$fromform->coursemodule", "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
@ -213,8 +203,8 @@
$fromform->name = get_string("modulename", $fromform->modulename); $fromform->name = get_string("modulename", $fromform->modulename);
} }
$return = $addinstancefunction($fromform); $returnfromfunc = $addinstancefunction($fromform);
if (!$return) { if (!$returnfromfunc) {
/*if (file_exists($moderr)) { /*if (file_exists($moderr)) {
$form = $fromform; $form = $fromform;
include_once($moderr); include_once($moderr);
@ -222,15 +212,15 @@
}*/ }*/
error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id"); error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id");
} }
if (is_string($return)) { if (is_string($returnfromfunc)) {
error($return, "view.php?id=$course->id"); error($returnfromfunc, "view.php?id=$course->id");
} }
if (!isset($fromform->groupmode)) { // to deal with pre-1.5 modules if (!isset($fromform->groupmode)) { // to deal with pre-1.5 modules
$fromform->groupmode = $course->groupmode; /// Default groupmode the same as course $fromform->groupmode = $course->groupmode; /// Default groupmode the same as course
} }
$fromform->instance = $return; $fromform->instance = $returnfromfunc;
// course_modules and course_sections each contain a reference // course_modules and course_sections each contain a reference
// to each other, so we have to update one of them twice. // to each other, so we have to update one of them twice.
@ -252,12 +242,6 @@
// make sure visibility is set correctly (in particular in calendar) // make sure visibility is set correctly (in particular in calendar)
set_coursemodule_visible($fromform->coursemodule, $fromform->visible); set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
if (isset($fromform->redirect)) {
$SESSION->returnpage = $fromform->redirecturl;
} else {
$SESSION->returnpage = "$CFG->wwwroot/mod/$fromform->modulename/view.php?id=$fromform->coursemodule";
}
add_to_log($course->id, "course", "add mod", add_to_log($course->id, "course", "add mod",
"../mod/$fromform->modulename/view.php?id=$fromform->coursemodule", "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
"$fromform->modulename $fromform->instance"); "$fromform->modulename $fromform->instance");
@ -270,12 +254,10 @@
rebuild_course_cache($course->id); rebuild_course_cache($course->id);
if (!empty($SESSION->returnpage)) { if ($return && isset($cm)){
$return = $SESSION->returnpage; redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id");
unset($SESSION->returnpage);
redirect($return);
} else { } else {
redirect("view.php?id=$course->id#section-$sectionreturn"); redirect("view.php?id=$course->id#section-".$cousesection);
} }
exit; exit;

View File

@ -99,6 +99,9 @@ class moodleform_mod extends moodleform {
$mform->addElement('hidden', 'update', 0); $mform->addElement('hidden', 'update', 0);
$mform->setType('update', PARAM_INT); $mform->setType('update', PARAM_INT);
$mform->addElement('hidden', 'return', 0);
$mform->setType('return', PARAM_BOOL);
} }
/** /**

47
lib/form/cancel.php Normal file
View File

@ -0,0 +1,47 @@
<?php
require_once('HTML/QuickForm/submit.php');
/**
* HTML class for a submit type element
*
* @author Jamie Pratt
* @access public
*/
class MoodleQuickForm_cancel extends HTML_QuickForm_submit
{
// {{{ constructor
/**
* Class constructor
*
* @since 1.0
* @access public
* @return void
*/
function MoodleQuickForm_cancel($elementName=null, $value=null, $attributes=null)
{
if ($elementName==null){
$elementName='cancel';
}
if ($value==null){
$value=get_string('cancel');
}
HTML_QuickForm_submit::HTML_QuickForm_submit($elementName, $value, $attributes);
$this->updateAttributes(array('onclick'=>'return this.form.submit();'));
} //end constructor
function onQuickFormEvent($event, $arg, &$caller)
{
switch ($event) {
case 'createElement':
$className = get_class($this);
$this->$className($arg[0], $arg[1], $arg[2]);
$caller->_registerCancelButton($this->getName());
return true;
break;
}
return parent::onQuickFormEvent($event, $arg, $caller);
} // end func onQuickFormEvent
// }}}
} //end class HTML_QuickForm_submit
?>

View File

@ -1,35 +0,0 @@
<?php
require_once('HTML/QuickForm/submit.php');
/**
* HTML class for a submit type element
*
* @author Jamie Pratt
* @access public
*/
class MoodleQuickForm_submit extends HTML_QuickForm_submit
{
// {{{ constructor
/**
* Class constructor
*
* @param string Input field name attribute
* @param string Input field value
* @param mixed Either a typical HTML attribute string or an associative array
* @since 1.0
* @access public
* @return void
*/
function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null)
{
HTML_QuickForm_submit::HTML_QuickForm_submit($elementName, $value, $attributes);
if ('cancel'==$elementName){
//bypass form validation js :
$this->updateAttributes(array('onclick'=>'return this.form.submit();'));
}
} //end constructor
} //end class HTML_QuickForm_submit
?>

View File

@ -63,12 +63,7 @@ class moodleform {
*/ */
var $_upload_manager; // var $_upload_manager; //
/**
* Array of buttons that if pressed do not result in the processing of the form.
*
* @var array
*/
var $_nosubmitbuttons=array();
/** /**
* The constructor function calls the abstract function definition() and it will then * The constructor function calls the abstract function definition() and it will then
@ -291,6 +286,21 @@ class moodleform {
return $validated; return $validated;
} }
/**
* Return true if a cancel button has been pressed resulting in the form being submitted.
*
* @return boolean true if a cancel button has been pressed
*/
function is_cancelled(){
$mform =& $this->_form;
foreach ($mform->_cancelButtons as $cancelbutton){
if (optional_param($cancelbutton, 0, PARAM_TEXT)){
return true;
}
}
return false;
}
/** /**
* Return submitted data if properly submitted or returns NULL if validation fails or * Return submitted data if properly submitted or returns NULL if validation fails or
* if there is no submitted data. * if there is no submitted data.
@ -299,13 +309,14 @@ class moodleform {
* @return object submitted data; NULL if not valid or not submitted * @return object submitted data; NULL if not valid or not submitted
*/ */
function data_submitted($slashed=true) { function data_submitted($slashed=true) {
foreach ($this->_nosubmitbuttons as $nosubmitbutton){ $mform =& $this->_form;
foreach ($mform->_noSubmitButtons as $nosubmitbutton){
if (optional_param($nosubmitbutton, 0, PARAM_TEXT)){ if (optional_param($nosubmitbutton, 0, PARAM_TEXT)){
return NULL; return NULL;
} }
} }
if ($this->is_submitted() and $this->is_validated()) { if ($this->is_submitted() and $this->is_validated()) {
$data = $this->_form->exportValues(null, $slashed); $data = $mform->exportValues(null, $slashed);
unset($data['sesskey']); // we do not need to return sesskey unset($data['sesskey']); // we do not need to return sesskey
unset($data['_qf__'.$this->_formname]); // we do not need the submission marker too unset($data['_qf__'.$this->_formname]); // we do not need the submission marker too
if (empty($data)) { if (empty($data)) {
@ -371,9 +382,7 @@ class moodleform {
return true; return true;
} }
function _register_no_submit_button($addfieldsname){
$this->_nosubmitbuttons[]=$addfieldsname;
}
/** /**
* Method to add a repeating group of elements to a form. * Method to add a repeating group of elements to a form.
@ -400,8 +409,8 @@ class moodleform {
if (!empty($addfields)){ if (!empty($addfields)){
$repeats += $addfieldsno; $repeats += $addfieldsno;
} }
$this->_register_no_submit_button($addfieldsname);
$mform =& $this->_form; $mform =& $this->_form;
$mform->_registerNoSubmitButton($addfieldsname);
$mform->addElement('hidden', $repeathiddenname, $repeats); $mform->addElement('hidden', $repeathiddenname, $repeats);
//value not to be overridden by submitted value //value not to be overridden by submitted value
$mform->setConstants(array($repeathiddenname=>$repeats)); $mform->setConstants(array($repeathiddenname=>$repeats));
@ -466,7 +475,18 @@ class moodleform {
class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
var $_types = array(); var $_types = array();
var $_dependencies = array(); var $_dependencies = array();
/**
* Array of buttons that if pressed do not result in the processing of the form.
*
* @var array
*/
var $_noSubmitButtons=array();
/**
* Array of buttons that if pressed do not result in the processing of the form.
*
* @var array
*/
var $_cancelButtons=array();
/** /**
* Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless * Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless
@ -870,6 +890,7 @@ function validate_' . $this->_attributes['id'] . '(frm) {
* @param string $dependentOn the name of the element whose state will be checked for * @param string $dependentOn the name of the element whose state will be checked for
* condition * condition
* @param string $condition the condition to check * @param string $condition the condition to check
* @param mixed $value used in conjunction with condition.
*/ */
function disabledIf($elementName, $dependentOn, $condition = 'notchecked', $value=null){ function disabledIf($elementName, $dependentOn, $condition = 'notchecked', $value=null){
$dependents = $this->_getElNamesRecursive($elementName); $dependents = $this->_getElNamesRecursive($elementName);
@ -880,6 +901,12 @@ function validate_' . $this->_attributes['id'] . '(frm) {
} }
} }
} }
function _registerNoSubmitButton($addfieldsname){
$this->_noSubmitButtons[]=$addfieldsname;
}
function _registerCancelButton($addfieldsname){
$this->_cancelButtons[]=$addfieldsname;
}
} }
@ -1034,7 +1061,7 @@ MoodleQuickForm::registerElementType('modvisible', "$CFG->libdir/form/modvisible
MoodleQuickForm::registerElementType('modgroupmode', "$CFG->libdir/form/modgroupmode.php", 'MoodleQuickForm_modgroupmode'); MoodleQuickForm::registerElementType('modgroupmode', "$CFG->libdir/form/modgroupmode.php", 'MoodleQuickForm_modgroupmode');
MoodleQuickForm::registerElementType('selectyesno', "$CFG->libdir/form/selectyesno.php", 'MoodleQuickForm_selectyesno'); MoodleQuickForm::registerElementType('selectyesno', "$CFG->libdir/form/selectyesno.php", 'MoodleQuickForm_selectyesno');
MoodleQuickForm::registerElementType('modgrade', "$CFG->libdir/form/modgrade.php", 'MoodleQuickForm_modgrade'); MoodleQuickForm::registerElementType('modgrade', "$CFG->libdir/form/modgrade.php", 'MoodleQuickForm_modgrade');
MoodleQuickForm::registerElementType('submit', "$CFG->libdir/form/submit.php", 'MoodleQuickForm_submit'); MoodleQuickForm::registerElementType('cancel', "$CFG->libdir/form/cancel.php", 'MoodleQuickForm_cancel');
MoodleQuickForm::registerElementType('button', "$CFG->libdir/form/button.php", 'MoodleQuickForm_button'); MoodleQuickForm::registerElementType('button', "$CFG->libdir/form/button.php", 'MoodleQuickForm_button');
MoodleQuickForm::registerElementType('choosecoursefile', "$CFG->libdir/form/choosecoursefile.php", 'MoodleQuickForm_choosecoursefile'); MoodleQuickForm::registerElementType('choosecoursefile', "$CFG->libdir/form/choosecoursefile.php", 'MoodleQuickForm_choosecoursefile');

View File

@ -94,14 +94,27 @@ function lockoptionsall(formid) {
function lockoptionsallsetup(formid) { function lockoptionsallsetup(formid) {
var items=eval(formid+'items'); var items=eval(formid+'items');
var form=document.forms[formid]; var form=document.forms[formid];
for (var master in items){ for (var i = 0; i < form.elements.length; i++){
form.elements[master].oldonclick = ((form.elements[master].onclick) ? form.elements[master].onclick : function () {}); var found=false;
form.elements[master].oldonblur = ((form.elements[master].onblur) ? form.elements[master].onblur : function () {}); var formelement = form.elements[i];
form.elements[master].oldonchange = ((form.elements[master].onchange) ? form.elements[master].onchange : function () {}); if (formelement.type=='reset'){
form.elements[master].onclick = function(){this.oldonclick(); return lockoptionsall(this.form.getAttribute('id'));}; formelement.onclick = function(){this.form.reset();return lockoptionsall(this.form.getAttribute('id'));};
form.elements[master].onblur = function(){this.oldonblur(); return lockoptionsall(this.form.getAttribute('id'));}; formelement.onblur = function(){this.form.reset();return lockoptionsall(this.form.getAttribute('id'));};
form.elements[master].onchange = function(){this.oldonchange(); return lockoptionsall(this.form.getAttribute('id'));}; formelement.onchange = function(){this.form.reset();return lockoptionsall(this.form.getAttribute('id'));};
} else {
for (var master in items){
if (master==formelement.name){
formelement.onclick = function(){return lockoptionsall(this.form.getAttribute('id'));};
formelement.onblur = function(){return lockoptionsall(this.form.getAttribute('id'));};
formelement.onchange = function(){return lockoptionsall(this.form.getAttribute('id'));};
break;
}
}
}
if (found){
}
} }
return lockoptionsall(formid); return lockoptionsall(formid);
} }

View File

@ -45,16 +45,14 @@ class chat_mod_form extends moodleform_mod {
$options[2] = get_string('numdays', '', 2); $options[2] = get_string('numdays', '', 2);
$mform->addElement('select', 'keepdays', get_string('savemessages', 'chat'), $options); $mform->addElement('select', 'keepdays', get_string('savemessages', 'chat'), $options);
$options=array(); $mform->addElement('selectyesno', 'studentlogs', get_string('studentseereports', 'chat'));
$options[0] = get_string('no');
$options[1] = get_string('yes');
$mform->addElement('select', 'studentlogs', get_string('studentseereports', 'chat'), $options);
$this->standard_coursemodule_elements(); $this->standard_coursemodule_elements();
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'reset', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -84,8 +84,9 @@ class choice_mod_form extends moodleform_mod {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -75,8 +75,9 @@ class data_mod_form extends moodleform_mod {
$this->standard_coursemodule_elements(); $this->standard_coursemodule_elements();
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -103,8 +103,9 @@ class exercise_mod_form extends moodleform_mod {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -127,8 +127,9 @@ class forum_mod_form extends moodleform_mod {
$this->standard_coursemodule_elements(); $this->standard_coursemodule_elements();
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -25,8 +25,9 @@ class glossary_comment_form extends moodleform {
$mform->setType('action', PARAM_ACTION); $mform->setType('action', PARAM_ACTION);
// buttons // buttons
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('reset', 'reset', get_string('revert')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
} }
} }

View File

@ -147,8 +147,9 @@ class glossary_mod_form extends moodleform_mod {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -47,8 +47,9 @@ class journal_mod_form extends moodleform_mod {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -17,8 +17,9 @@ class label_mod_form extends moodleform_mod {
$mform->addElement('modvisible', 'visible', get_string('visible')); $mform->addElement('modvisible', 'visible', get_string('visible'));
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }

View File

@ -276,8 +276,9 @@ class lesson_mod_form extends moodleform_mod {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
$buttonarray=array(); $buttonarray=array();
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel')); $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$renderer->addStopFieldsetElements('buttonar'); $renderer->addStopFieldsetElements('buttonar');
} }