添加更多输出smarty html选项

时间:2010-02-02 08:38:05

标签: php smarty

{html_options values=$row.milestone_id output=$row.title output=$row.title}

大家好,如何在smarty html选项中添加更多$ output?

1 个答案:

答案 0 :(得分:1)

输出需要是一个填充下拉列表的数组。参见示例

PHP代码

$smarty->assign('myOptions', array(
                                1800 => 'Joe Schmoe',
                                9904 => 'Jack Smith',
                                2003 => 'Charlie Brown')
                                );
$smarty->assign('mySelect', 9904);

然后是模板

{html_options name=foo options=$myOptions selected=$mySelect}

输出

<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>