I am attempting to create a dynamic form in PHP using the PHPLIB templating system. The issue I am running into is that I want to set default values in several input boxes, but they all have the same template variable name. Thus if I set the variable to be "A" in one place it sets the value in all input boxes to be "A".
So does anyone know of a way aroud this? Does anyone know if there is a way to dynamicly create template varialbes so each line items input box has a different template name?
template file looks something like this
<html>
<body>
<form action="{self}" method="post">
<!-- BEGIN data -->
Quantity: <input name="qty_{index}" value="{qty}">
Price: <input name="price_{index}" value={price}">
<!-- END data -->
</form>
</body>
</html>
PHP goes:
.
.
.
if (count($_POST) >= 1) {
if (checkErrors()) {
processForm();
} else {
for ($x = 0; $x < count($_POST); $x++) {
// Put data back in form so user can see errors
$t->set_var("qty", $_POST["qty_" . $x]);
$t->set_var("price", $_POST["price_" . $x]);
$t->parse("data_block", "data", true);
}
} // end if
.
.
.
Thanks
PHPdev