Re: html_options

messju mohr <[email protected]> Mon, 26 Feb 2007 14:23:50 +0100
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
On Mon, Feb 26, 2007 at 01:44:58PM +0100, Danilo Buerger wrote:
> messju mohr schrieb:
> >Hi,
> >
> >what about multiple selected values, then?
> 
> Good point, but that raises another bug. When using multiple selected 
> values, the <select> tag should have a multiple="multiple" attribute. Of 
> course this could be applied by a feature where every attribute in the 
> {html_options} that isnt one of values/output/selected/options/name is 
> appended to the <select> tag (if present).

It's the responsobility of the editor who inserts the {html_options}
into the template to declare it as multiple or not.

> So i guess the approach 
> should be if name is specified and multiple select values exist 
> multiple="multiple" should be automatically applied to the <select> tag 
> (if present). Here is a patch for this, which also fixes the first issue 
> but keeps the selected attribute as array:
> 
> Index: plugins/function.html_options.php
> ===================================================================
> RCS file: /repository/smarty/libs/plugins/function.html_options.php,v
> retrieving revision 1.25
> diff -r1.25 function.html_options.php
> 58c58
> <                 $$_key = array_map('strval', array_values((array)$_val));
> ---
> >                 $$_key = array_values((array)$_val);
> 90a91,93
> >         if (count($selected) > 1) {
> >             $extra = ' multiple="multiple"' . $extra;
> >         }

-1

the fact if an option list is single or multiple is most times rather
static, but the list of actually selected values is highly dynamic.

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php