2 require_once('HTML/QuickForm/advcheckbox.php');
5 * HTML class for a advcheckbox type element
7 * default behavior special for Moodle is to return '0' if not checked
10 * * @author Jamie Pratt
13 class MoodleQuickForm_advcheckbox
extends HTML_QuickForm_advcheckbox
{
15 * html for help button, if empty then no help
23 * @param string $elementName (optional)Input field name attribute
24 * @param string $elementLabel (optional)Input field label
25 * @param string $text (optional)Text to put after the checkbox
26 * @param mixed $attributes (optional)Either a typical HTML attribute string
27 * or an associative array
28 * @param mixed $values (optional)Values to pass if checked or not checked
34 function MoodleQuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null)
36 if ($values === null){
37 $values = array(0, 1);
39 parent
::HTML_QuickForm_advcheckbox($elementName, $elementLabel, $text, $attributes, $values);
44 * set html for help button
47 * @param array $help array of arguments to make a help button
48 * @param string $function function name to call to get html
50 function setHelpButton($helpbuttonargs, $function='helpbutton'){
51 if (!is_array($helpbuttonargs)){
52 $helpbuttonargs=array($helpbuttonargs);
54 $helpbuttonargs=$helpbuttonargs;
56 //we do this to to return html instead of printing it
57 //without having to specify it in every call to make a button.
58 if ('helpbutton' == $function){
59 $defaultargs=array('', '', 'moodle', true, false, '', true);
60 $helpbuttonargs=$helpbuttonargs +
$defaultargs ;
62 $this->_helpbutton
=call_user_func_array($function, $helpbuttonargs);
65 * get html for help button
68 * @return string html for help button
70 function getHelpButton(){
71 return $this->_helpbutton
;
74 * Automatically generates and assigns an 'id' attribute for the element.
76 * Currently used to ensure that labels work on radio buttons and
77 * advcheckboxes. Per idea of Alexander Radivanovich.
78 * Overriden in moodleforms to remove qf_ prefix.
83 function _generateId()
87 if (!$this->getAttribute('id')) {
88 $this->updateAttributes(array('id' => 'id_'.substr(md5(microtime() . $idx++
), 0, 6)));
90 } // end func _generateId
92 * Slightly different container template when frozen. Don't want to use a label tag
93 * with a for attribute in that case for the element label but instead use a div.
94 * Templates are defined in renderer constructor.
98 function getElementTemplateType(){
99 if ($this->_flagFrozen
){