2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
19 * submit type form element
21 * Contains HTML class for a submit type element
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");
31 * submit type form element
33 * HTML class for a submit type element
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
{
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);
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)
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
68 $onClick = $this->getAttribute('onclick');
69 $skip = 'skipClientValidation = true;';
70 $onClick = ($onClick !== null)?
$skip.' '.$onClick:$skip;
71 $this->updateAttributes(array('onclick'=>$onClick));
76 return parent
::onQuickFormEvent($event, $arg, $caller);
81 * Slightly different container template when frozen. Don't want to display a submit
82 * button if the form is frozen.
86 function getElementTemplateType(){
87 if ($this->_flagFrozen
){
90 return 'actionbuttons';
95 * Freeze the element so that only its value is returned
98 $this->_flagFrozen
= true;