weekly release 2.3dev
[moodle.git] / lib / form / submit.php
CommitLineData
a23f0aaf 1<?php
2require_once("HTML/QuickForm/submit.php");
3
4/**
5 * HTML class for a submit type element
6 *
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
12 */
13class MoodleQuickForm_submit extends HTML_QuickForm_submit {
3e8b394e 14 function MoodleQuickForm_submit($elementName=null, $value=null, $attributes=null) {
15 parent::HTML_QuickForm_submit($elementName, $value, $attributes);
16 }
a23f0aaf 17 /**
18 * Called by HTML_QuickForm whenever form event is made on this element
19 *
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
26 */
27 function onQuickFormEvent($event, $arg, &$caller)
28 {
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));
40 }
41 return true;
42 break;
43 }
44 return parent::onQuickFormEvent($event, $arg, $caller);
45
46 } // end func onQuickFormEvent
64360ee7 47 /**
48 * Slightly different container template when frozen. Don't want to display a submit
49 * button if the form is frozen.
50 *
51 * @return string
52 */
53 function getElementTemplateType(){
54 if ($this->_flagFrozen){
55 return 'nodisplay';
56 } else {
57 return 'default';
58 }
59 }
4a0e2e63 60
64360ee7 61 function freeze(){
62 $this->_flagFrozen = true;
63 }
4a0e2e63 64
a23f0aaf 65}