|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 require_once('HTML/QuickForm/checkbox.php'); 00003 00010 class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{ 00016 var $_helpbutton=''; 00017 function MoodleQuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) { 00018 parent::HTML_QuickForm_checkbox($elementName, $elementLabel, $text, $attributes); 00019 } 00027 function setHelpButton($helpbuttonargs, $function='helpbutton'){ 00028 debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead'); 00029 } 00036 function getHelpButton(){ 00037 return $this->_helpbutton; 00038 } 00039 00050 function onQuickFormEvent($event, $arg, &$caller) 00051 { 00052 //fixes bug in quickforms which lets previous set value override submitted value if checkbox is not checked 00053 // and no value is submitted 00054 switch ($event) { 00055 case 'updateValue': 00056 // constant values override both default and submitted ones 00057 // default values are overriden by submitted 00058 $value = $this->_findValue($caller->_constantValues); 00059 if (null === $value) { 00060 // if no boxes were checked, then there is no value in the array 00061 // yet we don't want to display default value in this case 00062 if ($caller->isSubmitted()) { 00063 $value = $this->_findValue($caller->_submitValues); 00064 } else { 00065 00066 $value = $this->_findValue($caller->_defaultValues); 00067 } 00068 } 00069 //fix here. setChecked should not be conditional 00070 $this->setChecked($value); 00071 break; 00072 default: 00073 parent::onQuickFormEvent($event, $arg, $caller); 00074 } 00075 return true; 00076 } // end func onQuickFormEvent 00077 function toHtml() 00078 { 00079 return '<span>' . parent::toHtml() . '</span>'; 00080 } 00081 00087 function getFrozenHtml() 00088 { 00089 //$this->_generateId(); 00090 $output = '<input type="checkbox" disabled="disabled" id="'.$this->getAttribute('id').'" '; 00091 if ($this->getChecked()) { 00092 $output .= 'checked="checked" />'.$this->_getPersistantData(); 00093 } else { 00094 $output .= '/>'; 00095 } 00096 return $output; 00097 } //end func getFrozenHtml 00098 }