Added optional fourth parameter to timezone_menu
allows setting one or more attributes on the generated select tag.
This allows passing attributes needed for Section 508 compliance ยง
1194.22(n), such as an id.
http://access-board.gov/sec508/guide/1194.22.htm#(n)
http://www.w3.org/TR/WCAG10-HTML-TECHS/#forms-labels
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index cafb6ba..fc790c5 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -547,9 +547,10 @@
* @param string timezone
* @param string classname
* @param string menu name
+ * @param mixed attributes
* @return string
*/
- function timezone_menu($default = 'UTC', $class = '', $name = 'timezones')
+ function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
{
$CI =& get_instance();
$CI->lang->load('date');
@@ -563,7 +564,22 @@
$menu .= ' class="'.$class.'"';
}
- $menu .= ">\n";
+ // Generate a string from the attributes submitted, if any
+ if (is_array($attributes))
+ {
+ $atts = '';
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ' '.$key.'="'.$val.'"';
+ }
+ $attributes = $atts;
+ }
+ elseif (is_string($attributes) && strlen($attributes) > 0)
+ {
+ $attributes = ' '.$attributes;
+ }
+
+ $menu .= $attributes.">\n";
foreach (timezones() as $key => $val)
{