From: jamiesensei Date: Thu, 28 Sep 2006 04:18:35 +0000 (+0000) Subject: now wrapping a group element in a fieldset tag, brought id tag on checkboxes and... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ec929cd596976c4af396c729ea6d995d80f6c7ef;p=moodle.git now wrapping a group element in a fieldset tag, brought id tag on checkboxes and radio boxes in line with moodle universal form structure --- diff --git a/lib/form/checkbox.php b/lib/form/checkbox.php index 9a7f6f9ee0..0817ca9b26 100644 --- a/lib/form/checkbox.php +++ b/lib/form/checkbox.php @@ -41,5 +41,23 @@ class moodleform_checkbox extends HTML_QuickForm_checkbox{ function getHelpButton(){ return $this->_helpbutton; } + /** + * Automatically generates and assigns an 'id' attribute for the element. + * + * Currently used to ensure that labels work on radio buttons and + * checkboxes. Per idea of Alexander Radivanovich. + * Overriden in moodleforms to remove qf_ prefix. + * + * @access private + * @return void + */ + function _generateId() + { + static $idx = 1; + + if (!$this->getAttribute('id')) { + $this->updateAttributes(array('id' => substr(md5(microtime() . $idx++), 0, 6))); + } + } // end func _generateId } ?> \ No newline at end of file diff --git a/lib/form/group.php b/lib/form/group.php index c0fa44ce32..f4fcc6e614 100644 --- a/lib/form/group.php +++ b/lib/form/group.php @@ -17,7 +17,7 @@ class moodleform_group extends HTML_QuickForm_group{ * @var string */ var $_helpbutton=''; - var $_elementTemplateType='default'; + var $_elementTemplateType='fieldset'; //would cause problems with client side validation so will leave for now //var $_elementTemplateType='fieldset'; /** diff --git a/lib/form/radio.php b/lib/form/radio.php index d9a57dae9b..f87638e800 100644 --- a/lib/form/radio.php +++ b/lib/form/radio.php @@ -41,5 +41,23 @@ class moodleform_radio extends HTML_QuickForm_radio{ function getHelpButton(){ return $this->_helpbutton; } + /** + * Automatically generates and assigns an 'id' attribute for the element. + * + * Currently used to ensure that labels work on radio buttons and + * checkboxes. Per idea of Alexander Radivanovich. + * Overriden in moodleforms to remove qf_ prefix. + * + * @access private + * @return void + */ + function _generateId() + { + static $idx = 1; + + if (!$this->getAttribute('id')) { + $this->updateAttributes(array('id' => substr(md5(microtime() . $idx++), 0, 6))); + } + } // end func _generateId } ?> \ No newline at end of file