html_optionsAttribute NameTypeRequiredDefaultDescriptionvaluesarrayYes, unless using options attributen/aan array of values for dropdownoutputarrayYes, unless using options attributen/aan array of output for dropdownselectedstring/arrayNoemptythe selected option element(s)optionsassociative arrayYes, unless using values and outputn/aan associative array of values and outputnamestringNoemptyname of select group
html_options is a custom function that creates html option group
with provided data. It takes care of which item(s) are selected by
default as well. Required attributes are values and output, unless
you use options instead.
If a given value is an array, it will treat it as an html OPTGROUP,
and display the groups. Recursion is supported with OPTGROUP. All
output is XHTML compatible.
If the optional name attribute is given, the
<select name="groupname"></select> tags will enclose
the option list. Otherwise only the option list is generated.
All parameters that are not in the list above are printed as
name/value-pairs inside the <select>-tag. They are ignored if
the optional name is not given.
html_options : Example 1
assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');
]]>
Where index.tpl is:
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
]]>
Example 2
assign('cust_options', array(
1001 => 'Joe Schmoe',
1002 => 'Jack Smith',
1003 => 'Jane Johnson',
1004 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');
]]>
Where index.tpl is:
{html_options options=$cust_options selected=$customer_id}
]]>
Both examples will output:
]]>