MDL-39888 mnet: Removal of an old sql statement invloving the mdl_log table.
[moodle.git] / lib / form / submit.php
blobaf94e4f6872fb9d83a0d4fbb9f3834c0338e4850
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * submit type form element
21 * Contains HTML class for a submit type element
23 * @package core_form
24 * @copyright 2006 Jamie Pratt <me@jamiep.org>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 require_once("HTML/QuickForm/submit.php");
30 /**
31 * submit type form element
33 * HTML class for a submit type element
35 * @package core_form
36 * @category form
37 * @copyright 2006 Jamie Pratt <me@jamiep.org>
38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40 class MoodleQuickForm_submit extends HTML_QuickForm_submit {
41 /**
42 * constructor
44 * @param string $elementName (optional) name of the field
45 * @param string $value (optional) field label
46 * @param string $attributes (optional) Either a typical HTML attribute string or an associative array
48 function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) {
49 parent::HTML_QuickForm_submit($elementName, $value, $attributes);
52 /**
53 * Called by HTML_QuickForm whenever form event is made on this element
55 * @param string $event Name of event
56 * @param mixed $arg event arguments
57 * @param object $caller calling object
59 function onQuickFormEvent($event, $arg, &$caller)
61 switch ($event) {
62 case 'createElement':
63 parent::onQuickFormEvent($event, $arg, $caller);
64 if ($caller->isNoSubmitButton($arg[0])){
65 //need this to bypass client validation
66 //for buttons that submit but do not process the
67 //whole form.
68 $onClick = $this->getAttribute('onclick');
69 $skip = 'skipClientValidation = true;';
70 $onClick = ($onClick !== null)?$skip.' '.$onClick:$skip;
71 $this->updateAttributes(array('onclick'=>$onClick));
73 return true;
74 break;
76 return parent::onQuickFormEvent($event, $arg, $caller);
80 /**
81 * Slightly different container template when frozen. Don't want to display a submit
82 * button if the form is frozen.
84 * @return string
86 function getElementTemplateType(){
87 if ($this->_flagFrozen){
88 return 'nodisplay';
89 } else {
90 return 'actionbuttons';
94 /**
95 * Freeze the element so that only its value is returned
97 function freeze(){
98 $this->_flagFrozen = true;