This demo shows the use of formtypes aka templates. In this demo only inline formtypes are used.
<?php
include ('../../libs/phpform.php');
?>
<html>
<head><title>PHP:Form Demo 3</title></head>
<body>
<h1>PHP:Form Demo 3</h1>
<p>This demo shows the use of formtypes aka templates. In this demo only inline formtypes are used.</p>
<php:form name="demo1">
<formtype name="text">
<label for="{var:id}">{var:label}</label><input type="text" name="{var:name}" id="{var:id}" value="{var:value}" /><br />
</formtype>
<!-- This is used as the begin HTML for this form (formtype 'begin' is a special type) -->
<formtype name="begin">
<![CDATA[<form name="{var:name}" method="POST">]]>
</formtype>
<!-- This is used as the end HTML for this form (formtype 'end' is a special type) -->
<formtype name="end">
<![CDATA[</form>]]>
</formtype>
<formfield type="text" id="field1" name="field1" label="Field 1: " />
<formfield type="text" id="field2" name="field2" label="Field 2: " />
<formfield type="text" id="field3" name="field3" label="Field 3: " />
<formfield type="text" id="field4" name="field4" label="Field 4: " value="this has a default value" />
<formfield type="text" id="field5" name="field5" label="Field 5: " />
<input type="submit" name="submit" value="Submit Form" />
</php:form>
<?php
// Does the form validate?
if (!$_FORMS->validate('demo1')) {
// Display form
$_FORMS->display('demo1');
} else {
// Print POST variables
echo '<pre>';
print_r ($_POST);
echo '</pre>';
}
// Show source (only for demo purposes)
echo '<h2>Source: </h2>';
highlight_file (__FILE__);
?>
</body>
</html>