2 require_once("HTML/QuickForm/text.php");
5 * HTML class for a text type element
10 class MoodleQuickForm_text
extends HTML_QuickForm_text
{
12 * html for help button, if empty then no help
17 var $_hiddenLabel=false;
19 function MoodleQuickForm_text($elementName=null, $elementLabel=null, $attributes=null) {
20 parent
::HTML_QuickForm_text($elementName, $elementLabel, $attributes);
23 function setHiddenLabel($hiddenLabel){
24 $this->_hiddenLabel
= $hiddenLabel;
27 if ($this->_hiddenLabel
){
29 return '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.
30 $this->getLabel().'</label>'.parent
::toHtml();
32 return parent
::toHtml();
36 * Automatically generates and assigns an 'id' attribute for the element.
38 * Currently used to ensure that labels work on radio buttons and
39 * checkboxes. Per idea of Alexander Radivanovich.
40 * Overriden in moodleforms to remove qf_ prefix.
45 function _generateId()
49 if (!$this->getAttribute('id')) {
50 $this->updateAttributes(array('id' => 'id_'. substr(md5(microtime() . $idx++
), 0, 6)));
52 } // end func _generateId
54 * set html for help button
57 * @param array $help array of arguments to make a help button
58 * @param string $function function name to call to get html
60 function setHelpButton($helpbuttonargs, $function='helpbutton'){
61 if (!is_array($helpbuttonargs)){
62 $helpbuttonargs=array($helpbuttonargs);
64 $helpbuttonargs=$helpbuttonargs;
66 //we do this to to return html instead of printing it
67 //without having to specify it in every call to make a button.
68 if ('helpbutton' == $function){
69 $defaultargs=array('', '', 'moodle', true, false, '', true);
70 $helpbuttonargs=$helpbuttonargs +
$defaultargs ;
72 $this->_helpbutton
=call_user_func_array($function, $helpbuttonargs);
75 * get html for help button
78 * @return string html for help button
80 function getHelpButton(){
81 return $this->_helpbutton
;
84 * Slightly different container template when frozen. Don't want to use a label tag
85 * with a for attribute in that case for the element label but instead use a div.
86 * Templates are defined in renderer constructor.
90 function getElementTemplateType(){
91 if ($this->_flagFrozen
){