我是PHPTAL的第一次用户,我无法使用PHPTAL提供输入框的价值,我有三个文件1.index.php
require_once 'includes/lib/PHPTAL-1.2.2/PHPTAL.php';
// create a new template object
$template = new PHPTAL('components/epayroll/new/employeeView.xhtml');
require_once("employeeClass.php");
$people = array();
$people[] = new Person("foo");
// put some data into the template context
$template->title = 'The title value';
$template->people = $people;
// execute the template
try {
echo $template->execute();
}
catch (Exception $e){
echo $e;
}2.empView.Xhtml
<td> <tal:block metal:define-macro="text"> <input name="${name}"
tal:attributes="id id | nothing" type="text" value="person/name"
/> </tal:block> </td>3.empClass.php
class Person {
public $name;
function Person($name){
$this->name = $name;
}
}请帮助我的步骤如何做到这一点。
谢谢你的宝贵回应
发布于 2014-01-24 23:29:51
在employeeView.xhtml中,您需要迭代人员:
<div tal:repeat="person people">
<!-- you can use person here -->
</div>如果要调用宏,则:
<div tal:repeat="person people">
<div metal:use-macro="text" />
</div>如果希望数组键用作if,也可以将类似tal:define="id repeat/person/key"的内容添加到内部<div>中。
要设置<input>值,请使用:
<input value="${person/name}">这是对以下几个方面的简短说明:
<input tal:attributes="value person/name">https://stackoverflow.com/questions/21305007
复制相似问题