From ea2c699f5cb6b85d1a73cbeda4df86a008b75f28 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 7 Feb 2008 02:54:11 +0000 Subject: [PATCH] allow the link-query method of an app to set further attributes of the option used to display the entry, eg. a title (tooltip) of a certain entry: instead of id => title pairs, you return eg id => array(label=>title,title=>tooltip) like for html::select or the select widget --- etemplate/inc/class.link_widget.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.link_widget.inc.php b/etemplate/inc/class.link_widget.inc.php index e2f80300fd..26d995e0c0 100644 --- a/etemplate/inc/class.link_widget.inc.php +++ b/etemplate/inc/class.link_widget.inc.php @@ -632,9 +632,17 @@ else { $script = "var select = document.getElementById('$id_res');\nselect.options.length=0;\n"; - foreach($found as $id => $title) + foreach($found as $id => $option) { - $script .= "select.options[select.options.length] = new Option('".addslashes($title)."','$id');\n"; + if (!is_array($option)) $option = array('label' => $option); + $script .= "opt = select.options[select.options.length] = new Option('".addslashes($option['label'])."','$id');\n"; + if (count($option) > 1) + { + foreach($option as $name => $value) + { + if ($name != 'label') $script .= "opt.$name = '".addslashes($value)."';\n"; + } + } } $script .= "select.options[select.options.length] = new Option('".addslashes(lang('New search').' ...')."','');\n"; foreach(explode(',',$id_show) as $id)