Merge branch 'wip-MDL-26747' of git://github.com/sammarshallou/moodle
[moodle.git] / lib / form / submit.php
blob3b6fd906f22d329280a77b65f110c5f954424ceb
1 <?php
2 require_once("HTML/QuickForm/submit.php");
4 /**
5 * HTML class for a submit type element
7 * @author Adam Daniel <adaniel1@eesus.jnj.com>
8 * @author Bertrand Mansion <bmansion@mamasam.com>
9 * @version 1.0
10 * @since PHP4.04pl1
11 * @access public
13 class MoodleQuickForm_submit extends HTML_QuickForm_submit {
14 function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) {
15 parent::HTML_QuickForm_submit($elementName, $value, $attributes);
17 /**
18 * Called by HTML_QuickForm whenever form event is made on this element
20 * @param string $event Name of event
21 * @param mixed $arg event arguments
22 * @param object $caller calling object
23 * @since 1.0
24 * @access public
25 * @return void
27 function onQuickFormEvent($event, $arg, &$caller)
29 switch ($event) {
30 case 'createElement':
31 parent::onQuickFormEvent($event, $arg, $caller);
32 if ($caller->isNoSubmitButton($arg[0])){
33 //need this to bypass client validation
34 //for buttons that submit but do not process the
35 //whole form.
36 $onClick = $this->getAttribute('onclick');
37 $skip = 'skipClientValidation = true;';
38 $onClick = ($onClick !== null)?$skip.' '.$onClick:$skip;
39 $this->updateAttributes(array('onclick'=>$onClick));
41 return true;
42 break;
44 return parent::onQuickFormEvent($event, $arg, $caller);
46 } // end func onQuickFormEvent
47 /**
48 * Slightly different container template when frozen. Don't want to display a submit
49 * button if the form is frozen.
51 * @return string
53 function getElementTemplateType(){
54 if ($this->_flagFrozen){
55 return 'nodisplay';
56 } else {
57 return 'default';
61 function freeze(){
62 $this->_flagFrozen = true;