Example 8-12. Associative array with the options attribute
Code:
<?php
$smarty->assign('myOptions', array(
1800 => 'Joe Schmoe',
9904 => 'Jack Smith',
2003 => 'Charlie Brown')
);
$smarty->assign('mySelect', 9904);
?>
The following template will generate a drop-down list. Note the presence of the name attribute which creates the <select> tags.
Code:
{html_options name=foo options=$myOptions selected=$mySelect}
Output of the above example would be:
Code:
<select name="foo">
<option label="Joe Schmoe" value="1800">Joe Schmoe</option>
<option label="Jack Smith" value="9904" selected="selected">Jack Smith</option>
<option label="Charlie Brown" value="2003">Charlie Brown</option>
</select>