diff --git a/change_log.txt b/change_log.txt
index 75f2aee0..79268ce8 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -1,4 +1,8 @@
===== SVN trunk =====
+
+21/12/2010
+- update html_options to support class and id attrs
+
17/12/2010
- bugfix added missing support of $cache_attrs for registered plugins
diff --git a/libs/plugins/function.html_options.php b/libs/plugins/function.html_options.php
index 65c77c65..7ac03902 100644
--- a/libs/plugins/function.html_options.php
+++ b/libs/plugins/function.html_options.php
@@ -37,12 +37,17 @@ function smarty_function_html_options($params, $template)
$options = null;
$selected = array();
$output = null;
+ $id = null;
+ $class = null;
$extra = '';
+ $options_extra = '';
foreach($params as $_key => $_val) {
switch ($_key) {
case 'name':
+ case 'class':
+ case 'id':
$$_key = (string)$_val;
break;
@@ -74,43 +79,52 @@ function smarty_function_html_options($params, $template)
/* raise error here? */
$_html_result = '';
+ $_idx = 0;
if (isset($options)) {
- foreach ($options as $_key => $_val)
- $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
+ foreach ($options as $_key => $_val) {
+ $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
+ }
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
- $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
+ $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
}
}
if (!empty($name)) {
- $_html_result = '' . "\n";
+ $_html_class = !empty($class) ? ' class="'.$class.'"' : '';
+ $_html_id = !empty($id) ? ' id="'.$id.'"' : '';
+ $_html_result = '' . "\n";
}
return $_html_result;
}
-function smarty_function_html_options_optoutput($key, $value, $selected)
+function smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, &$idx)
{
if (!is_array($value)) {
$_html_result = '' . "\n";
+ $idx++;
} else {
- $_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
- }
+ $_idx = 0;
+ $_html_result = smarty_function_html_options_optgroup($key, $value, $selected, $id.'-'.$idx, $class, $_idx);
+ $idx++;
+ }
return $_html_result;
}
-function smarty_function_html_options_optgroup($key, $values, $selected)
+function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx)
{
$optgroup_html = '\n";
return $optgroup_html;