html_options,用于生成下拉列表
常见属性如下图:
select.php(后端):
<?php
include 'libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->template_dir = "templates";
$smarty->compile_dir = "templates_c";
$man = array(
5 => '张三',
6 => '梅兰芳',
7 => '张学良',
8 => '李四'
);
$smarty->assign('man',$man);
$smarty->display('select.tpl');
select.tpl(前端视图):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<h2>html_options的用法</h2>
<label for="">请选出你心目中的美男:</label>
{html_options name = 'man' options = $man selected = 6} {* options=关联数组,关联数组的下标分配给values,数组的值对应显示出来的部分 *}
<!--
<select name="" id="">
<option value=""></option>
<option value=""></option>
</select>
-->
</body>
</html>