看到getField方法 于是在FormAction.class.php控制器中建立如下函数
public function ti
tle(){
$Form = M("Form");
// 获取标题
$title= $Form->where('id=3')->getField('title');
if($title) {
dump($title);
$this->title = $title;// 模板变量赋值
}else{
$this->error('数据错误');
}
$this->display();
}
在TPL/Form中建立title.html
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
{$title.title}
</body>
</html>
在浏览器中测试 http://localhost/index.php/Form/title 只能得到一个字母 神马原因