Merge branch 'wip-MDL-26747' of git://github.com/sammarshallou/moodle
[moodle.git] / lib / form / textarea.php
blob7587ddfa1dae379ba2ee8ce57ee799f178e52627
1 <?php
2 require_once('HTML/QuickForm/textarea.php');
4 /**
5 * HTML class for a textarea type element
7 * @author Jamie Pratt
8 * @access public
9 */
10 class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
11 /**
12 * Need to store id of form as we may need it for helpbutton
14 * @var string
16 var $_formid = '';
17 /**
18 * html for help button, if empty then no help
20 * @var string
22 var $_helpbutton='';
24 var $_hiddenLabel=false;
26 function MoodleQuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) {
27 parent::HTML_QuickForm_textarea($elementName, $elementLabel, $attributes);
29 /**
30 * set html for help button
32 * @access public
33 * @param array $help array of arguments to make a help button
34 * @param string $function function name to call to get html
36 function setHelpButton($helpbuttonargs, $function='helpbutton'){
37 debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
39 /**
40 * get html for help button
42 * @access public
43 * @return string html for help button
45 function getHelpButton(){
46 return $this->_helpbutton;
49 function setHiddenLabel($hiddenLabel){
50 $this->_hiddenLabel = $hiddenLabel;
53 function toHtml(){
54 if ($this->_hiddenLabel){
55 $this->_generateId();
56 return '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' .
57 $this->getLabel() . '</label>' . parent::toHtml();
58 } else {
59 return parent::toHtml();
63 /**
64 * Called by HTML_QuickForm whenever form event is made on this element
66 * @param string $event Name of event
67 * @param mixed $arg event arguments
68 * @param object $caller calling object
69 * @since 1.0
70 * @access public
71 * @return void
73 function onQuickFormEvent($event, $arg, &$caller)
75 switch ($event) {
76 case 'createElement':
77 $this->_formid = $caller->getAttribute('id');
78 break;
80 return parent::onQuickFormEvent($event, $arg, $caller);
81 } // end func onQuickFormEvent
82 /**
83 * Slightly different container template when frozen.
85 * @return string
87 function getElementTemplateType(){
88 if ($this->_flagFrozen){
89 return 'static';
90 } else {
91 return 'default';