From 7540dede0f01acd7aa1ffd224defc5189305a815 Mon Sep 17 00:00:00 2001 From: Mat Whitney Date: Fri, 22 Jun 2012 12:02:10 -0700 Subject: Added optional fourth parameter to timezone_menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- system/helpers/date_helper.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index cafb6ba95..fc790c585 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -547,9 +547,10 @@ if ( ! function_exists('timezone_menu')) * @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 @@ if ( ! function_exists('timezone_menu')) $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) { -- cgit v1.2.3-24-g4f1b